Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Current Time on form

Status
Not open for further replies.

waiwainoo

MIS
Apr 18, 2005
17
GB
I want to show Current system time on a form.
I have a text box named text2 , in its properties Control Sourse is set to =Now().

Problem is that it displays the system time but do not update itself when the time changes.

plz help me.
 
waiwainoo,

Take a look at the form's Timer property and the OnTimer event.

Ken S.
 
waiwainoo,

Here's the routine I use to accomplish this. In this example, txtOmega takes the place of your text2. In order to have the time continuously updated, you have to use the Form Timer. Each time it clicks over the time is re-written and thus updated.

First, so that the time will be displayed for the initial period while the form and timer are "firing up", I put this in the Sub Form_Open.


Private Sub Form_Open(Cancel As Integer)
Me("txtOmega") = Right$(Now, 11) 'So that Time display
is visible while
waiting for timer
to crank up
End Sub

Then the following sub:

Private Sub Form_Timer()
Me("txtOmega") = Right$(Now, 11) 'Continuously updates
the Time display
End Sub

This gives the time in hours-minutes-seconds, with the seconds continuously ticking over. BTW, the Control Source is left blank. All the work is done in the VBA code.

Hope this helps!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Missingling
The Compiler comes up with an error highligting "Right$"
do you know what it is about ?

Waiting..
Thanks
 
Set the following easy method
Form's TimerInterval=1000
Code:
Private Sub Form_Timer()
    Me.Text2 = Time
End Sub

________________________________________
Zameer Abdulla
Visit Me
There is only one perfect child in this world. Every mother has it.
 
Thanks ZmrAbdulla

It did worked ... Big releaf :)

Thanks again

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top