PC Review


Reply
Thread Tools Rate Thread

Date on UserForm?

 
 
TotallyConfused
Guest
Posts: n/a
 
      23rd Oct 2009
I have a UserForm with a multipage on the first page I have a textbox that I
have assigned Form Date. I want "todays date" to fill the text box on
opening the form. It was working fine but after changes to the form the date
is not visible when form is loaded. I have the following code on

Private Sub UserForm1_Initialize()
Load UserForm1
UserForm1.Show
frmMyUserform.Show vbModeless
Me.txtFormDate = Date
'Me.txtFormDate = format(date,"mm-dd-yyyy")

End Sub

I have tried the following variations with no success. Can someone please
help me with this? Thank you in advance for any help you can provide.

Me.FormDate.Text = Format(Date, "mm-dd-yyyy")
Me.txtFormDate = Date
Me.FormDate = Format(Date, "mm-dd-yyyy")

 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      23rd Oct 2009
This will do..The Initialize() event is fired when you Load the userform...

Private Sub UserForm_Initialize()
Me.txtFormDate = Date
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"TotallyConfused" wrote:

> I have a UserForm with a multipage on the first page I have a textbox that I
> have assigned Form Date. I want "todays date" to fill the text box on
> opening the form. It was working fine but after changes to the form the date
> is not visible when form is loaded. I have the following code on
>
> Private Sub UserForm1_Initialize()
> Load UserForm1
> UserForm1.Show
> frmMyUserform.Show vbModeless
> Me.txtFormDate = Date
> 'Me.txtFormDate = format(date,"mm-dd-yyyy")
>
> End Sub
>
> I have tried the following variations with no success. Can someone please
> help me with this? Thank you in advance for any help you can provide.
>
> Me.FormDate.Text = Format(Date, "mm-dd-yyyy")
> Me.txtFormDate = Date
> Me.FormDate = Format(Date, "mm-dd-yyyy")
>

 
Reply With Quote
 
TotallyConfused
Guest
Posts: n/a
 
      23rd Oct 2009
Thank you Jacob for responding. However, this did not work. Is there
anything else I can do to get the date to show when form is open? What would
cause this? Thank you.

"Jacob Skaria" wrote:

> This will do..The Initialize() event is fired when you Load the userform...
>
> Private Sub UserForm_Initialize()
> Me.txtFormDate = Date
> End Sub
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "TotallyConfused" wrote:
>
> > I have a UserForm with a multipage on the first page I have a textbox that I
> > have assigned Form Date. I want "todays date" to fill the text box on
> > opening the form. It was working fine but after changes to the form the date
> > is not visible when form is loaded. I have the following code on
> >
> > Private Sub UserForm1_Initialize()
> > Load UserForm1
> > UserForm1.Show
> > frmMyUserform.Show vbModeless
> > Me.txtFormDate = Date
> > 'Me.txtFormDate = format(date,"mm-dd-yyyy")
> >
> > End Sub
> >
> > I have tried the following variations with no success. Can someone please
> > help me with this? Thank you in advance for any help you can provide.
> >
> > Me.FormDate.Text = Format(Date, "mm-dd-yyyy")
> > Me.txtFormDate = Date
> > Me.FormDate = Format(Date, "mm-dd-yyyy")
> >

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      23rd Oct 2009
Check whether you have named your userform in-correctly.. Place a message box
in Initialize event to see whether it is getting displayed.

'Code behind form
Private Sub UserForm1_Initialize()
Me.txtFormDate = Date
End Sub

'Macro to be placed in a module...Try running this macro..
Sub Macro()
Load UserForm1
UserForm1.Show
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"TotallyConfused" wrote:

> Thank you Jacob for responding. However, this did not work. Is there
> anything else I can do to get the date to show when form is open? What would
> cause this? Thank you.
>
> "Jacob Skaria" wrote:
>
> > This will do..The Initialize() event is fired when you Load the userform...
> >
> > Private Sub UserForm_Initialize()
> > Me.txtFormDate = Date
> > End Sub
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "TotallyConfused" wrote:
> >
> > > I have a UserForm with a multipage on the first page I have a textbox that I
> > > have assigned Form Date. I want "todays date" to fill the text box on
> > > opening the form. It was working fine but after changes to the form the date
> > > is not visible when form is loaded. I have the following code on
> > >
> > > Private Sub UserForm1_Initialize()
> > > Load UserForm1
> > > UserForm1.Show
> > > frmMyUserform.Show vbModeless
> > > Me.txtFormDate = Date
> > > 'Me.txtFormDate = format(date,"mm-dd-yyyy")
> > >
> > > End Sub
> > >
> > > I have tried the following variations with no success. Can someone please
> > > help me with this? Thank you in advance for any help you can provide.
> > >
> > > Me.FormDate.Text = Format(Date, "mm-dd-yyyy")
> > > Me.txtFormDate = Date
> > > Me.FormDate = Format(Date, "mm-dd-yyyy")
> > >

 
Reply With Quote
 
TotallyConfused
Guest
Posts: n/a
 
      23rd Oct 2009
Thank you Jacob, but this does not make the date on the text box visible. I
noticed though that when I click in design view the date textbox and go to
View Code I get this which I have not before. It seems I get this "Change",
even when I click on the view Code for the Multi Page. Maybe this is an
indication of what is wrong? What does this mean? Thank you.

Private Sub txtFormDate_Change()

End Sub

"Jacob Skaria" wrote:

> Check whether you have named your userform in-correctly.. Place a message box
> in Initialize event to see whether it is getting displayed.
>
> 'Code behind form
> Private Sub UserForm1_Initialize()
> Me.txtFormDate = Date
> End Sub
>
> 'Macro to be placed in a module...Try running this macro..
> Sub Macro()
> Load UserForm1
> UserForm1.Show
> End Sub
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "TotallyConfused" wrote:
>
> > Thank you Jacob for responding. However, this did not work. Is there
> > anything else I can do to get the date to show when form is open? What would
> > cause this? Thank you.
> >
> > "Jacob Skaria" wrote:
> >
> > > This will do..The Initialize() event is fired when you Load the userform...
> > >
> > > Private Sub UserForm_Initialize()
> > > Me.txtFormDate = Date
> > > End Sub
> > >
> > > If this post helps click Yes
> > > ---------------
> > > Jacob Skaria
> > >
> > >
> > > "TotallyConfused" wrote:
> > >
> > > > I have a UserForm with a multipage on the first page I have a textbox that I
> > > > have assigned Form Date. I want "todays date" to fill the text box on
> > > > opening the form. It was working fine but after changes to the form the date
> > > > is not visible when form is loaded. I have the following code on
> > > >
> > > > Private Sub UserForm1_Initialize()
> > > > Load UserForm1
> > > > UserForm1.Show
> > > > frmMyUserform.Show vbModeless
> > > > Me.txtFormDate = Date
> > > > 'Me.txtFormDate = format(date,"mm-dd-yyyy")
> > > >
> > > > End Sub
> > > >
> > > > I have tried the following variations with no success. Can someone please
> > > > help me with this? Thank you in advance for any help you can provide.
> > > >
> > > > Me.FormDate.Text = Format(Date, "mm-dd-yyyy")
> > > > Me.txtFormDate = Date
> > > > Me.FormDate = Format(Date, "mm-dd-yyyy")
> > > >

 
Reply With Quote
 
Coder1215
Guest
Posts: n/a
 
      24th Oct 2009
Hi,

I don't know if this answers your question exactly, but there is an
interesting way to put such information on the form. First you must
put an empty label on the form (with caption set to empty) and put the
following code in the Form initialization event:

Private Sub UserForm_Initialize()
Me.lblFormOpenDateTime.Caption = "This form was opened exactly at
" & vbCrLf _
& Date & " " & Time & " " & "by user " & Application.UserName
End Sub

Each time the form will be initialized (loaded to memory) you will see
the date/time/user combination in the label. For the change event you
could use timestamp which is also interesting information for the
user.

regards
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get a date to display in date format on a UserForm ryguy7272 Microsoft Excel Programming 12 22nd Mar 2008 10:31 PM
Date on UserForm TotallyConfused Microsoft Excel Programming 1 5th Dec 2007 08:21 PM
Userform Date Paul Brown Microsoft Excel Programming 2 21st Sep 2005 09:56 PM
Re: Date in userform being saved as general not date which affects sor Michael Malinsky Microsoft Excel Programming 0 28th Jul 2004 06:58 PM
Userform to select start date and end date Johnny B. Microsoft Excel Programming 0 28th Nov 2003 05:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.