Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Real Time clock (2000)

    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

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Flims, Switzerland
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    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.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    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.

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Flims, Switzerland
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    Very true about the interval, 400ms would be better - good thinking.

  5. #5
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    Where can you get a timer control of the type you guys refer to?

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Real Time clock (2000)

    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

  7. #7
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    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.

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Real Time clock (2000)

    Does it say something like "Microsoft Access can't find the Macro clock." and then some other stuff?
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    Yes.

  10. #10
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Real Time clock (2000)

    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

  11. #11
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    Thanks, Rory. Everything's working perfectly.

  12. #12
    Star Lounger
    Join Date
    Jan 2001
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    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

  13. #13
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Real Time clock (2000)

    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

  14. #14
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Real Time clock (2000)

    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?

  15. #15
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Real Time clock (2000)

    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

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •