I've added the date and time in the header of the form and would like to make the time update every 5 seconds while in Form view.
Is there code I can write to make this possible?
The name of the text box is "Auto_Time"
I've added the date and time in the header of the form and would like to make the time update every 5 seconds while in Form view.
Is there code I can write to make this possible?
The name of the text box is "Auto_Time"
Most developers let Windows take care of the time but if you must, use the Timer event of the form.
Sorry, I would like the time on the form to refresh every 5 seconds so the time viewed on the form can stay current with the time in windows. I don't want the time shown to stay stagnate, I want it the stay current.
As I said, use the Timer interrupt set at 5000. It is still resource intensive and sucks up a bunch of cpu cycles.
I've used these, for years, on a series of apps that had to be 'full-screen,' and have never had any resource problems, but RG's advice is given by many experts. I suspect that with today's faster processors it's not as much of a problem as it used to be! But, as they say, your mileage may vary!
For your Textbox:
Code:Private Sub Form_Open(Cancel As Integer) 'Displays while waiting for timer to crank up Me.Auto_Time = Now Me.TimerInterval = 5000 End Sub Private Sub Form_Timer() Me.Auto_Time = Now End Sub
I really prefer doing this with a Label instead of a Textbox:
Code:Private Sub Form_Open(Cancel As Integer) 'Displays while waiting for timer to crank up Me.MyClock.Caption = Now Me.TimerInterval = 5000 End Sub Private Sub Form_Timer() Me.MyClock.Caption = Now End Sub
Also note that if you should start experiencing problems with 'screen-flicker' the Timer usage may be responsible!
Linq ;0)>