Is there a way to have a real time clock appear on a form? Not using a time funtion to display the current time when the form is opened, but a clock that is changing the seconds and minutes right on the screen.... Is there a way to do that?
-Kelley
Is there a way to have a real time clock appear on a form? Not using a time funtion to display the current time when the form is opened, but a clock that is changing the seconds and minutes right on the screen.... Is there a way to do that?
-Kelley

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
One way would be to drop a timer control on the form and set it's interval to 1000 (milliseconds). In it's Timer event, make it update a label with the current time. That would make the label perform like a real time clock.
How real do you want the time to be?
You could add a timer (say at 400 ms) to update a control on the form. Using it at 1000 ms may cause it to 'jump' 2 seconds at times, that is why a shorter interval is better.
However it will only work when the timer event fires and Access updates the form. If you really require it to display more accurately then you will require a special (third party) control or some serious programming on your part.
Very true about the interval, 400ms would be better - good thinking.
Where can you get a timer control of the type you guys refer to?
Hi,
If you look at the bottom of the Form's events list, there's On Timer and Timer Interval.
Hope that helps.
Regards,
Rory
Microsoft MVP - Excel.
I'm using A2K. I want to place a real-time clock on a form. I added a label called Clock and placed the following code in the form's On Timer event procedure: Clock.Caption = Format (Time, "hh:mm AM/PM"). Why won't the clock work? When I run the form, I'm presented with an error dialog that says something about a macro error.
Does it say something like "Microsoft Access can't find the Macro clock." and then some other stuff?
Regards,
Rory
Microsoft MVP - Excel.
Yes.
OK, so I assume you just typed that code into the box next to On Timer? Unfortunately, it's not quite that easy - you need to click in the On Timer box, clear that code out, click on the button with '...' on it, choose Code Builder and then put that code into the procedure that Access creates for you (between the Private Sub... and End Sub lines). When you close the VBEditor window, you should see [Event Procedure] in the box next to On Timer and then hopefully everything should work OK (I'm assuming you have already set the Timer Interval value)
Hope that helps.
Regards,
Rory
Microsoft MVP - Excel.
Thanks, Rory. Everything's working perfectly.
Rory - I got it to work using the Event Procedure as well showing just the time. However, can I have it display the current date and time on that same line? Or would it be easier to put it in two different controls? I just can't seem to get the Clock.Caption=Format (Time, "hh:mm:ss AM/PM") in the right syntax to get it to also display the date. Thanks!
-Kelley
Hi Kelley,
Yes you can - you'd need something like:
Clock.Caption = Format(Now,"dd/mm/yyyy hh:mm:ss AM/PM)
You can change the formatting to suit your needs.
Hope that helps.
Regards,
Rory
Microsoft MVP - Excel.
I created the real time clock on my main switchboard form using the method described above, and it works perfectly...on my computer only. When any other users open the database, they are immediately taken to the VBA de######, with the message "Can't Find Object or Library" and "Time" in the code Format (Time... highlighted. Any ideas what is happening?
On the other machines, in the VBEditor window, if you select Tools-References from the menu, do any references appear with MISSING: in front of them? If so, uncheck the reference and try compiling the database.
Regards,
Rory
Microsoft MVP - Excel.