User Form with a field showing current date / time

  • Thread starter Thread starter jennie
  • Start date Start date
J

jennie

Hi,

Is there any way of having a field in the user form, that each time i
is loaded (the form is opened) it displays the current date and tim
(i.e. the date and time the form was opened)?

I am new to using user forms so detailed explaination, instruction
would be great.

Thanks in advance
Jenni
 
Place a label on your Userform. and then add the code below to the UserForm
module

Private Sub UserForm_Initialize()
Label1.Caption = Format(Now, "dd mmm yyyy hh:mm")
End Sub


--
XL2002
Regards

William

(e-mail address removed)

| Hi,
|
| Is there any way of having a field in the user form, that each time it
| is loaded (the form is opened) it displays the current date and time
| (i.e. the date and time the form was opened)?
|
| I am new to using user forms so detailed explaination, instructions
| would be great.
|
| Thanks in advance
| Jennie
|
|
| ---
| Message posted
|
 
Suggest using the Activate event in case the form gets hidden.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi Bob

Not that I doubt your advice, but please could you explain in a little more
detail why you'd use the Activate, rather than the Initialize, event.
Thanks.

--
XL2002
Regards

William

(e-mail address removed)

| Suggest using the Activate event in case the form gets hidden.
|
| --
|
| HTH
|
| Bob Phillips
| ... looking out across Poole Harbour to the Purbecks
| (remove nothere from the email address if mailing direct)
|
| | > Place a label on your Userform. and then add the code below to the
| UserForm
| > module
| >
| > Private Sub UserForm_Initialize()
| > Label1.Caption = Format(Now, "dd mmm yyyy hh:mm")
| > End Sub
| >
| >
| > --
| > XL2002
| > Regards
| >
| > William
| >
| > (e-mail address removed)
| >
| > | > | Hi,
| > |
| > | Is there any way of having a field in the user form, that each time it
| > | is loaded (the form is opened) it displays the current date and time
| > | (i.e. the date and time the form was opened)?
| > |
| > | I am new to using user forms so detailed explaination, instructions
| > | would be great.
| > |
| > | Thanks in advance
| > | Jennie
| > |
| > |
| > | ---
| > | Message posted
| > |
| >
| >
|
|
 
Because the Initialize event would be fired when the form is loaded, whereas
Activate is fired when the form is shown. In a typical sequence, this
happens

Userform1.Show (this fires Initialize the Activate as the form is not yet in
memory)
Userform1.Hide
Userform1.Show (this fires ACtivate, but not Initialize as it is alreadyt
in memory)
etc.

so you see Activate always fires, Initialize doesn't.

ANother way is

Load Userform1 (fires Initialize, but the form is only loaded into memory,
not shown)
Userform1.Show (fires Activate only this toime, as already in memory, and
shows it)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thanks.
--
XL2002
Regards

William

(e-mail address removed)

| Because the Initialize event would be fired when the form is loaded,
whereas
| Activate is fired when the form is shown. In a typical sequence, this
| happens
|
| Userform1.Show (this fires Initialize the Activate as the form is not yet
in
| memory)
| Userform1.Hide
| Userform1.Show (this fires ACtivate, but not Initialize as it is alreadyt
| in memory)
| etc.
|
| so you see Activate always fires, Initialize doesn't.
|
| ANother way is
|
| Load Userform1 (fires Initialize, but the form is only loaded into memory,
| not shown)
| Userform1.Show (fires Activate only this toime, as already in memory, and
| shows it)
|
| --
|
| HTH
|
| Bob Phillips
| ... looking out across Poole Harbour to the Purbecks
| (remove nothere from the email address if mailing direct)
|
| | > Hi Bob
| >
| > Not that I doubt your advice, but please could you explain in a little
| more
| > detail why you'd use the Activate, rather than the Initialize, event.
| > Thanks.
| >
| > --
| > XL2002
| > Regards
| >
| > William
| >
| > (e-mail address removed)
| >
| > | > | Suggest using the Activate event in case the form gets hidden.
| > |
| > | --
| > |
| > | HTH
| > |
| > | Bob Phillips
| > | ... looking out across Poole Harbour to the Purbecks
| > | (remove nothere from the email address if mailing direct)
| > |
| > | | > | > Place a label on your Userform. and then add the code below to the
| > | UserForm
| > | > module
| > | >
| > | > Private Sub UserForm_Initialize()
| > | > Label1.Caption = Format(Now, "dd mmm yyyy hh:mm")
| > | > End Sub
| > | >
| > | >
| > | > --
| > | > XL2002
| > | > Regards
| > | >
| > | > William
| > | >
| > | > (e-mail address removed)
| > | >
| > | > | > | > | Hi,
| > | > |
| > | > | Is there any way of having a field in the user form, that each
time
| it
| > | > | is loaded (the form is opened) it displays the current date and
time
| > | > | (i.e. the date and time the form was opened)?
| > | > |
| > | > | I am new to using user forms so detailed explaination,
instructions
| > | > | would be great.
| > | > |
| > | > | Thanks in advance
| > | > | Jennie
| > | > |
| > | > |
| > | > | ---
| > | > | Message posted
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top