The clock on forms

  • Thread starter Thread starter Dragan
  • Start date Start date
D

Dragan

Hi.

Do you know how to create the clock on forms in Access?

I create a Label called lblClock on the form and write this code.

Private Sub Form_Timer()
Me!lblClock.Caption = Format(Now, "dddd, mmmm yyyy, hh:mm:ss AMPM")
End Sub

Private Sub cmdClockStart_Click()
Me.TimerInterval = 1000
End Sub

Private Sub cmdClockEnd_Click()
Me.TimerInterval = 0
End Sub

These code working but I most always click on the label lblClock.

I just want to the clock with normaly time on the form, no break or no
click.

Thanks
 
Dragan said:
Hi.

Do you know how to create the clock on forms in Access?

I create a Label called lblClock on the form and write this code.

Private Sub Form_Timer()
Me!lblClock.Caption = Format(Now, "dddd, mmmm yyyy, hh:mm:ss AMPM")
End Sub

Private Sub cmdClockStart_Click()
Me.TimerInterval = 1000
End Sub

Private Sub cmdClockEnd_Click()
Me.TimerInterval = 0
End Sub

These code working but I most always click on the label lblClock.

I just want to the clock with normaly time on the form, no break or no
click.

Thanks
Open your form in design mode.

Open properties for the FORM.

Click on the Events tab

In the Timer Interval field (at the bottom of the page), enter 1000

Save and close


The "cmdClockStart_Click()" and "cmdClockEnd_Click()" are not necessary; you
can keep them or delete them.

Sometimes it is nice to be able to turn off the clock if you have time
intensive subroutines.


Steve
 
Thank you Steve

I have a small problem. On the Event tab I cant find Timer Interval field.
Just On Click, On Dbl Click, On Mouse Down, On Mouse Move and On Mouse Up.

Can You Please write to me all procedure than creating label to the end?

1. Open the form (like Switchboard)
2. Open form in design mode.
3. Click on the label tool
4. Drawing the field named lclClick (Properties for the FORM: Caption is
lclClick and Name Label4.)

This is OK? Whats next?

Thanks
 
Where are you looking for the Timer Interval field? It's a property of the
form, not of the label.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Dragan said:
Thank you Steve

I have a small problem. On the Event tab I cant find Timer Interval field.
Just On Click, On Dbl Click, On Mouse Down, On Mouse Move and On Mouse Up.

Can You Please write to me all procedure than creating label to the end?

1. Open the form (like Switchboard)
2. Open form in design mode.
3. Click on the label tool
4. Drawing the field named lclClick (Properties for the FORM: Caption is
lclClick and Name Label4.)

This is OK? Whats next?

Thanks
 
Open the form in design mode. On the far left there is the ruler. At the top
of the form is also a ruler. Where the two rulers meet is a box. Click in the
box. A black square should appear. In the menu bar, click on the properties
icon (the hand holding the paper).

Click on the events tab. The bottom field should have 1000 in it. The second
from the bottom is the "OnTimer" event field and should show [Event
Procedure]. This event is where the code to update the label caption is
placed and looks like this:

Private Sub Form_Timer()
Me!lblClock.Caption = Format(Now, "dddd, mmmm yyyy, hh:mm:ss AMPM")
End Sub


You only need the code above and 1000 in the Interval timer field.


Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Dragan said:
Thank you Steve

I have a small problem. On the Event tab I cant find Timer Interval field.
Just On Click, On Dbl Click, On Mouse Down, On Mouse Move and On Mouse Up.

Can You Please write to me all procedure than creating label to the end?

1. Open the form (like Switchboard)
2. Open form in design mode.
3. Click on the label tool
4. Drawing the field named lclClick (Properties for the FORM: Caption is
lclClick and Name Label4.)

This is OK? Whats next?

Thanks
 
Its working Steve!!!

Thank You Very Much


SteveS said:
Open the form in design mode. On the far left there is the ruler. At the
top
of the form is also a ruler. Where the two rulers meet is a box. Click in
the
box. A black square should appear. In the menu bar, click on the
properties
icon (the hand holding the paper).

Click on the events tab. The bottom field should have 1000 in it. The
second
from the bottom is the "OnTimer" event field and should show [Event
Procedure]. This event is where the code to update the label caption is
placed and looks like this:

Private Sub Form_Timer()
Me!lblClock.Caption = Format(Now, "dddd, mmmm yyyy, hh:mm:ss AMPM")
End Sub


You only need the code above and 1000 in the Interval timer field.


Steve
 
Back
Top