N
Nick T
Hi,
With help from various, i have created a timer on my form which counts down
when the form is opened. As my db is developing, i am wanting to make an
adjustment/addition:
'Timer1' for this example is set to 10 seconds.
Basically, when 'timer 1' = 0, i want 'Timer2' to start at 0 and count up in
hh,mm,ss.
I have the following code in my forms open event:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Open_Click
DoCmd.GoToRecord , , acNewRec
dteStartTime = DateAdd("s", 10, Now())
Me.TimerInterval = 1000
Me.Text4 = ""
Me.Text4.BackColor = vbWhite
Exit_Open_Click:
Exit Sub
Err_Open_Click:
MsgBox Err.Description
End Sub
and this code in my ontimer event for the form:
Private Sub Form_Timer()
If DateDiff("s", Now, dteStartTime) < 0 Then
Me.TimerInterval = 0
Me.Text4 = "Check Required"
Me.Text4.BackColor = vbRed
Else
varCounter = "00:0" & Int(DateDiff("s", Now, dteStartTime) / 60)
varCounter = varCounter & ":" _
& Right("0" & DateDiff("s", Now, dteStartTime) Mod 60, 2)
Me.Timer1 = varCounter
End If
End Sub
I have played around with some sample code for timers (as on the net) etc,
but cant seem to figure it out!
Any suggestions?
Thanks
With help from various, i have created a timer on my form which counts down
when the form is opened. As my db is developing, i am wanting to make an
adjustment/addition:
'Timer1' for this example is set to 10 seconds.
Basically, when 'timer 1' = 0, i want 'Timer2' to start at 0 and count up in
hh,mm,ss.
I have the following code in my forms open event:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Open_Click
DoCmd.GoToRecord , , acNewRec
dteStartTime = DateAdd("s", 10, Now())
Me.TimerInterval = 1000
Me.Text4 = ""
Me.Text4.BackColor = vbWhite
Exit_Open_Click:
Exit Sub
Err_Open_Click:
MsgBox Err.Description
End Sub
and this code in my ontimer event for the form:
Private Sub Form_Timer()
If DateDiff("s", Now, dteStartTime) < 0 Then
Me.TimerInterval = 0
Me.Text4 = "Check Required"
Me.Text4.BackColor = vbRed
Else
varCounter = "00:0" & Int(DateDiff("s", Now, dteStartTime) / 60)
varCounter = varCounter & ":" _
& Right("0" & DateDiff("s", Now, dteStartTime) Mod 60, 2)
Me.Timer1 = varCounter
End If
End Sub
I have played around with some sample code for timers (as on the net) etc,
but cant seem to figure it out!
Any suggestions?
Thanks