Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current date

Hi All, How can I display current system date on my excel userform in one of
the fields? Foe eg, lets say I have a Date Field on my userform, I want it to
display current system date everytime Anyone opens the userform, also it
shouldnt be editable by the users, but just visible.

Thanks in Advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Display Current date

I prefer using a label if I don't want users to be able to edit. For
example, if I create an appropriately sized Label1 inside UserForm1, then
this would do what you want.

'---------------------------------
Private Sub UserForm_Activate()
Label1.Caption = "Today is " & FormatDateTime(Date, vbLongDate)
End Sub

'--------------------------------

Steve Yandl




"sam" wrote in message
...
Hi All, How can I display current system date on my excel userform in one
of
the fields? Foe eg, lets say I have a Date Field on my userform, I want it
to
display current system date everytime Anyone opens the userform, also it
shouldnt be editable by the users, but just visible.

Thanks in Advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current date

Thanks for the help steve, I have used a textbox and similar code like yours:

Private Sub UserForm_Activate()
Me.ReqDt.Value = Date
End Sub

But for some reason the textbox still doesnt display the system date when i
launch the userform. This code is place at the top of my vb code for
userform. could it be an issue with where i put this code?

Thanks in Advance


"Steve Yandl" wrote:

I prefer using a label if I don't want users to be able to edit. For
example, if I create an appropriately sized Label1 inside UserForm1, then
this would do what you want.

'---------------------------------
Private Sub UserForm_Activate()
Label1.Caption = "Today is " & FormatDateTime(Date, vbLongDate)
End Sub

'--------------------------------

Steve Yandl




"sam" wrote in message
...
Hi All, How can I display current system date on my excel userform in one
of
the fields? Foe eg, lets say I have a Date Field on my userform, I want it
to
display current system date everytime Anyone opens the userform, also it
shouldnt be editable by the users, but just visible.

Thanks in Advance



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Display Current date

Hi Sam, Try UserForm_Initialize instead of UserForm_Activate.


"sam" wrote in message
...
Thanks for the help steve, I have used a textbox and similar code like
yours:

Private Sub UserForm_Activate()
Me.ReqDt.Value = Date
End Sub

But for some reason the textbox still doesnt display the system date when
i
launch the userform. This code is place at the top of my vb code for
userform. could it be an issue with where i put this code?

Thanks in Advance


"Steve Yandl" wrote:

I prefer using a label if I don't want users to be able to edit. For
example, if I create an appropriately sized Label1 inside UserForm1, then
this would do what you want.

'---------------------------------
Private Sub UserForm_Activate()
Label1.Caption = "Today is " & FormatDateTime(Date, vbLongDate)
End Sub

'--------------------------------

Steve Yandl




"sam" wrote in message
...
Hi All, How can I display current system date on my excel userform in
one
of
the fields? Foe eg, lets say I have a Date Field on my userform, I want
it
to
display current system date everytime Anyone opens the userform, also
it
shouldnt be editable by the users, but just visible.

Thanks in Advance





  #5   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current date

Still the same... I have set the text box: locked property to True so the
users cannot input in this field. But I still dont see the system date in
this field. Does the location of my code matter here?

Thanks in Advance

"JLGWhiz" wrote:

Hi Sam, Try UserForm_Initialize instead of UserForm_Activate.


"sam" wrote in message
...
Thanks for the help steve, I have used a textbox and similar code like
yours:

Private Sub UserForm_Activate()
Me.ReqDt.Value = Date
End Sub

But for some reason the textbox still doesnt display the system date when
i
launch the userform. This code is place at the top of my vb code for
userform. could it be an issue with where i put this code?

Thanks in Advance


"Steve Yandl" wrote:

I prefer using a label if I don't want users to be able to edit. For
example, if I create an appropriately sized Label1 inside UserForm1, then
this would do what you want.

'---------------------------------
Private Sub UserForm_Activate()
Label1.Caption = "Today is " & FormatDateTime(Date, vbLongDate)
End Sub

'--------------------------------

Steve Yandl




"sam" wrote in message
...
Hi All, How can I display current system date on my excel userform in
one
of
the fields? Foe eg, lets say I have a Date Field on my userform, I want
it
to
display current system date everytime Anyone opens the userform, also
it
shouldnt be editable by the users, but just visible.

Thanks in Advance







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Display Current date

Your code should be in the UserForm code module. Right click the form in
design mode and click view code, or double click the form, to open the code
window. Both syntax work. The Initialize event populates the TextBox as
soon as the form appears. The Activate event requires that you click on the
form, since the focus automatically goes to the TextBox. I tested both and
both work, so you just need to get the code in the right place.


"sam" wrote in message
...
Still the same... I have set the text box: locked property to True so the
users cannot input in this field. But I still dont see the system date in
this field. Does the location of my code matter here?

Thanks in Advance

"JLGWhiz" wrote:

Hi Sam, Try UserForm_Initialize instead of UserForm_Activate.


"sam" wrote in message
...
Thanks for the help steve, I have used a textbox and similar code like
yours:

Private Sub UserForm_Activate()
Me.ReqDt.Value = Date
End Sub

But for some reason the textbox still doesnt display the system date
when
i
launch the userform. This code is place at the top of my vb code for
userform. could it be an issue with where i put this code?

Thanks in Advance


"Steve Yandl" wrote:

I prefer using a label if I don't want users to be able to edit. For
example, if I create an appropriately sized Label1 inside UserForm1,
then
this would do what you want.

'---------------------------------
Private Sub UserForm_Activate()
Label1.Caption = "Today is " & FormatDateTime(Date, vbLongDate)
End Sub

'--------------------------------

Steve Yandl




"sam" wrote in message
...
Hi All, How can I display current system date on my excel userform
in
one
of
the fields? Foe eg, lets say I have a Date Field on my userform, I
want
it
to
display current system date everytime Anyone opens the userform,
also
it
shouldnt be editable by the users, but just visible.

Thanks in Advance







  #7   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current date

Thanks for your help, It is working now.. I was doing UserForm1.Initialize()
.. As my userform name is UserForm1. My new code is working fine now. Also
using just the Date didnt work, I had to do DateTime.Date

Private Sub UserForm_Initialize()
Me.ReqDt.Value = DateTime.Date
End Sub

"JLGWhiz" wrote:

Your code should be in the UserForm code module. Right click the form in
design mode and click view code, or double click the form, to open the code
window. Both syntax work. The Initialize event populates the TextBox as
soon as the form appears. The Activate event requires that you click on the
form, since the focus automatically goes to the TextBox. I tested both and
both work, so you just need to get the code in the right place.


"sam" wrote in message
...
Still the same... I have set the text box: locked property to True so the
users cannot input in this field. But I still dont see the system date in
this field. Does the location of my code matter here?

Thanks in Advance

"JLGWhiz" wrote:

Hi Sam, Try UserForm_Initialize instead of UserForm_Activate.


"sam" wrote in message
...
Thanks for the help steve, I have used a textbox and similar code like
yours:

Private Sub UserForm_Activate()
Me.ReqDt.Value = Date
End Sub

But for some reason the textbox still doesnt display the system date
when
i
launch the userform. This code is place at the top of my vb code for
userform. could it be an issue with where i put this code?

Thanks in Advance


"Steve Yandl" wrote:

I prefer using a label if I don't want users to be able to edit. For
example, if I create an appropriately sized Label1 inside UserForm1,
then
this would do what you want.

'---------------------------------
Private Sub UserForm_Activate()
Label1.Caption = "Today is " & FormatDateTime(Date, vbLongDate)
End Sub

'--------------------------------

Steve Yandl




"sam" wrote in message
...
Hi All, How can I display current system date on my excel userform
in
one
of
the fields? Foe eg, lets say I have a Date Field on my userform, I
want
it
to
display current system date everytime Anyone opens the userform,
also
it
shouldnt be editable by the users, but just visible.

Thanks in Advance








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display current date on chart Tail Wind Excel Discussion (Misc queries) 5 April 3rd 23 03:45 PM
need info to display only after date is current and stay there Cindyt Excel Discussion (Misc queries) 4 April 30th 10 01:51 PM
Have current date display in File Name ploddinggaltn Excel Programming 1 October 24th 06 02:37 PM
how do I display username, current time & date on the status bar Gary Tan Excel Programming 4 July 25th 06 06:29 AM
Can I display the current date in a text box? stephiebrady Excel Discussion (Misc queries) 2 December 2nd 05 02:45 PM


All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"