OnTime Problem
Looks to me that these modifications will work:
Public RunWhen1 As Double
Public RunWhen2 As Double
Public Sub StartTimer1()
'StartTimer1 start vanaf 05:00 uur
'MsgBox "Timer1 gestart"
RunWhen1 = TimeSerial(5, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen1, _
Procedu="StartTimer2", Schedule:=True
End Sub
Public Sub StartTimer2()
'StartTimer2 start als StartTimer1 om 05:00 uur
'geactiveerd is geworden
'De Timer functie wordt overgegeven aan Timer2
RunWhen2 = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen2, _
Procedu="PrintenOpTijd", Schedule:=True
End Sub
Public Sub StopTimer1()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen1, _
Procedu="StartTimer2", Schedule:=False
'MsgBox "Timer1 is gestopt"
End Sub
Public Sub StopTimer2()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen2, _
Procedu="PrintenOpTijd", Schedule:=False
'MsgBox "Timer2 is gestopt"
End Sub
Note that the procedures called in the StopTimerN() subs are (and
have to be) the same ones called in the StartTimerN() subs.
From your description, I suspect that StartTimer1() should set
RunWhen1 to
TimeSerial(5, 0, 0)
so that StartTimer2 is called at 5:00:00 rather than 5:00:15.
Also, I didn't see anything that called StartTimer1, which would be
required if you want this code to cycle every day.
In article ,
"Peter Pantus" wrote:
Here is the code
The message boxes are in Dutch. I hope that is not a problem
Many Thanks in advance
|