- database solutions and downloads for microsoft access

Microsoft Access Forms

Create a working clock on your forms

Looking for that extra special effect to give your Microsoft Access database project a professional flair...Thought about adding a working clock to your Access forms?

To put a simple text clock on a form, create a Label called lblClock on the form, set the form's TimerInterval to 1000, and the following code behind the Timer Event.

You can also create two command buttons called cmdClockStart and cmdClockEnd and attach respective code to each to have the clock run on demand.

'***************** Code Start ***************
Private Sub Form_Timer()
    Me!lblClock.Caption = Format(Now, "dddd, mmm d 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
'***************** Code End ***************

Clock control on switchboard

The above Microsoft Access database form shows the clock as it would appear using the code. I have omitted to include the Clock Start and Clock End buttons as detailed in the above code sample.