Tracking time for an event

R

Ron

I have a form and I would like to put a timer on it. I want to be able to
click a button and the timer will start, then click the same button and the
timer will stop. The time will show up in two other fields. One field will
have hours and the other field will have minutes. Can this be done?

Thanks,
Ron
 
B

Brian

Ron said:
I have a form and I would like to put a timer on it. I want to be able to
click a button and the timer will start, then click the same button and the
timer will stop. The time will show up in two other fields. One field will
have hours and the other field will have minutes. Can this be done?

Thanks,
Ron

In the button's Click event, set the form's TimerInterval property to 60000
if it is currently zero, or to zero if it is currently not zero i.e.

If Me.TimerInterval = 0 Then
Me!txtHours = 0
Me!txtMinutes = 0
Me.TimerInterval = 60000
Else
Me.TimerInterval = 0
End If

In the form's Timer event, update the values of the text boxes e.g.

If Me!txtMinutes = 59 Then
Me!txtHours = Me!txtHours + 1
Me!txtMinutes = 0
Else
Me!txtMinutes = Me!txtMinutes + 1
End If
 
Top