Ok I have a label that counts down from 10 minutes then runs some code in a module then the timer resets back to to minutes and it keeps running untill I shut the form down. I have two issues here and I cant figure out how to do them or what to add into the VBA.
Issue one:
The button on my form starts the countdown of a ten minute timer then runs the code as explained above. I want to be able to on the first time I hit the cmdRunLogger button I want to run the events in the module then start the countdown and do a continuous cycle there like I already have.
Issue two:
I want to add a stop and I figure once issue one is resolved I would be able to just use "sTimerOn = False" Correct? BUT what if I wanted to pause the timer, how would I do that in a button and resume it?
I did however create a button called cmdPausePLCLogger and tried the below code but it just goofed up the loop numbers... But the buttons fipping back and forth is what I wanted.
Thanks,
SoggyCashew.....
Issue one:
The button on my form starts the countdown of a ten minute timer then runs the code as explained above. I want to be able to on the first time I hit the cmdRunLogger button I want to run the events in the module then start the countdown and do a continuous cycle there like I already have.
Issue two:
I want to add a stop and I figure once issue one is resolved I would be able to just use "sTimerOn = False" Correct? BUT what if I wanted to pause the timer, how would I do that in a button and resume it?
Code:
Public Loops As Integer
Dim sTimerOn As Boolean
Private Sub cmdRunLogger_Click()
sTimerOn = True
End Sub
Private Sub Form_Timer()
Static StartTime As Date
Dim SecondsToCount As Integer
SecondsToCount = 600 'Set this variable to the total number of seconds to count down
If sTimerOn = True Then
If Loops = 0 Then StartTime = Time
Min = (SecondsToCount - DateDiff("s", StartTime, Time)) \ 60
Sec = (SecondsToCount - DateDiff("s", StartTime, Time)) Mod 60
Me.lblCountDown.Caption = "Next Table Update " & Min & ":" & Format(Sec, "00")
Loops = Loops + 1
If Me.lblCountDown.Caption = "Next Table Update 0:00" Then
'Run functions in modUtilities
'DO SOME STUFF
Loops = 0 'Resets Timer
End If
End If
End Sub
I did however create a button called cmdPausePLCLogger and tried the below code but it just goofed up the loop numbers... But the buttons fipping back and forth is what I wanted.
Code:
Private Sub cmdPausePLCLogger_Click()
If Me.cmdPausePLCLogger.Caption = "Pause" Then
Me.cmdPausePLCLogger.Caption = "Resume"
Me.txtHiddenLoops.Value = Loops
sTimerOn = False
ElseIf Me.cmdPausePLCLogger.Caption = "Resume" Then
Me.cmdPausePLCLogger.Caption = "Pause"
sTimerOn = True
Loops = Me.txtHiddenLoops.Value
Me.txtHiddenLoops = Null
End If
End Sub
Thanks,
SoggyCashew.....