Clock

Little_Man22

Registered User.
Local time
Today, 22:47
Joined
Jun 23, 2001
Messages
118
I have a form and I want to insert a clock on it that counts down from 2:00, 1:59, 1:58...etc and then beeps when it gets to 0.

I would like it if the clock resets itself every time the user tabs to a new entry within the form. Any ideas?

Thanks in advance,
Ryan.
 
You can build a clock from a text box. Set the form's Timer Interval property to some positive integer (100 should work well), and use form's On Timer event procedure to update the clock every time the timer fires. You'll probably want a Sub to initialize the clock to 2:00 and store the time of the initialization, plus another one to decrement it (but not to less than 0). Check the help screens for the Time() and DateDiff() functions. You could call the initialization Sub when the form loads, and as part of the OnEnter event procedure for each control on the form.
 
You could also put that event in the control's GetFocus routines for text boxes, but you would have to add it to the Click routines for any command buttons.

The timer can resolve times on the order of milliseconds, but the finer you resolve the time, the greater the overhead. For something so simple as a clock countdown, I would set the form's timer to 1000 (=1000 milliseconds= 1 second) and recompute the time string each time. As simple as that function is, you could just keep minutes and seconds as separate counters, do the hexagesimal math yourself, and just format the results.
 
I can get a clock to appear on my form but I am after a clock that starts at 2:00 and counts down to 0.

I don't care about saving the time elapsed or anything. I am actually running a hockey draft and the picks are being entered through an Access form. One of the rules is that an individual only has 2 mins to make his pick (hence the timer that I need).

Any ideas as to what the necessary code would look like?

Ryan.
 
At the beginning, compute and record the desired end time. In the OnTimer event procedure, update your "countdown" clock by computing the time remaining from Now() until the recorded end time. I think you can do it with the DateAdd and TimeValue functions, but you'll have to play with these.

[This message has been edited by AlanS (edited 08-22-2001).]
 

Users who are viewing this thread

Back
Top Bottom