M
MikeS
I have a simple program that refreshes a form once every minute ( or what
ever increment I decide) It is basically two functions - one that requeries
the data and updates the form and one that does the timer.
Private Function RefreshData()
Dim intCountLine0 As Integer, intCountLine2 As Integer, intCountLine3 As
Integer
If IsNull(intCountLine0 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine0")) Then
Cancel = True
Else
intCountLine0 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine0")
End If
If IsNull(intCountLine2 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine2")) Then
Cancel = True
Else
intCountLine2 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine2")
End If
If IsNull(intCountLine3 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine3")) Then
Cancel = True
Else
intCountLine3 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine3")
End If
Me.TotalLine0 = intCountLine0
Me.TotalLine2 = intCountLine2
Me.TotalLine3 = intCountLine3
Me.Refresh
If blnTimerOff = False Then
Application.Run MyTimer2
End If
End Function
Public Function MyTimer2()
Dim intPause As Integer
Dim dtStop As Date
lblTime.Caption = "Updated: " & Format(Now(), "hh:mm:ss")
intPause = 60
dtStop = DateAdd("s", intPause, Now())
Do Until (Now() >= dtStop) Or blnTimerOff
DoEvents
Loop
If blnTimerOff = False Then
Application.Run RefreshData
End If
End Function
Private Sub btnExit_Click()
blnTimerOff = True
DoCmd.Close
End Sub
Whenever I close or "Exit" the form, I get an error which I suspect is
because the timer is still in the loop. I also have tried using the
"blnTimerOff = True" statement in the OnClose and OnUnload events but that
doesn't fix the problem either.
Does anyone have any suggestions.
Thanks,
Mike
ever increment I decide) It is basically two functions - one that requeries
the data and updates the form and one that does the timer.
Private Function RefreshData()
Dim intCountLine0 As Integer, intCountLine2 As Integer, intCountLine3 As
Integer
If IsNull(intCountLine0 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine0")) Then
Cancel = True
Else
intCountLine0 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine0")
End If
If IsNull(intCountLine2 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine2")) Then
Cancel = True
Else
intCountLine2 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine2")
End If
If IsNull(intCountLine3 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine3")) Then
Cancel = True
Else
intCountLine3 = DLookup("[Count Of UnitsByDay]",
"UnitsByDayLine3")
End If
Me.TotalLine0 = intCountLine0
Me.TotalLine2 = intCountLine2
Me.TotalLine3 = intCountLine3
Me.Refresh
If blnTimerOff = False Then
Application.Run MyTimer2
End If
End Function
Public Function MyTimer2()
Dim intPause As Integer
Dim dtStop As Date
lblTime.Caption = "Updated: " & Format(Now(), "hh:mm:ss")
intPause = 60
dtStop = DateAdd("s", intPause, Now())
Do Until (Now() >= dtStop) Or blnTimerOff
DoEvents
Loop
If blnTimerOff = False Then
Application.Run RefreshData
End If
End Function
Private Sub btnExit_Click()
blnTimerOff = True
DoCmd.Close
End Sub
Whenever I close or "Exit" the form, I get an error which I suspect is
because the timer is still in the loop. I also have tried using the
"blnTimerOff = True" statement in the OnClose and OnUnload events but that
doesn't fix the problem either.
Does anyone have any suggestions.
Thanks,
Mike