Need to show continuous time in the form

N

naveen prasad

hi all,
In my form I want to show continous system time,

it should show according to system time

I tried to add text box, and in form properties - on load event

text1.set focus
text1.text = now() this is showing date & time when form is loaded

but this is not correct , it is not changing as per system time continously

pls help
 
M

Marshall Barton

naveen said:
In my form I want to show continous system time,

it should show according to system time

I tried to add text box, and in form properties - on load event

text1.set focus
text1.text = now() this is showing date & time when form is loaded

but this is not correct , it is not changing as per system time continously


Do you really need to do that? The Windows task bar has a
decent clock going all the time.

If you have to have your own clock on your form, you need to
put the code in the form's Timer event with the
TimerInterval property set to the number of milliseconds
between updating the text box.

BTW, your old VB is showing ;-)
The Text property in Access is NOT used to set a text box's
value. Instead, use the Value property, which is the
default property so you do not even need to specify it. The
timer event code would simply be:
text1 = now()

BUT, there are consequences to using a timer event and in
general you should avoid using it. The primary consquence
is that you can not edit a VBA module while a timer is
running. The VBA editor thinks it is in charge of
keystrokes and suddenly your form gets control so the
keystrokes are going to the wrong place.
 
N

naveen prasad

i really did not understand your concept.

kindly give me simple solution so that i can implement...

regards
 
J

John Spencer

Apologies for butting in

That is about as simple as it gets.

In the form that has the time showing.

Set the Timer Interval property to 1000 (that is one second)
Set code in the Timer Interval event.

Private Sub Form_Timer()
Me.Text1 = Time()
End Sub

Now once every second while the form is open the Form_Timer event will execute
and update Text1 with the current system time.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 

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

Top