Ok here is a tough one. I have a form that contains a timer. Two actually. The problem is that the second timer, won't always function. I've tried using If conditions to keep it from firing if the variable advtime is Null, but for some reason, this doesn't work. The idea is to replace ElapsedTime function with the AdviseElapsed Function in the Timer Event and continue to count down the new value.
Private Sub Form_Timer()
'Declair the Dimmensions
Dim currtime As Date
Dim deptime As Date
Dim split As Date
Dim advsplit As Date
Dim advtime As Date
'Start the Main Clock after loading the Departure Time
If IsNull(Me.txtdeptime.Value) Then
Exit Sub
End If
If IsNotNull(Me.txtadvtime.Value) Then
Me.txtsplittime.Value = Format(advsplit, "hh:nn:ss")
End If
'Define the Dimmensions
currtime = Me.txtcurrtime.Value
deptime = Me.txtdeptime.Value
split = ElapsedTime(deptime, currtime)
advsplit = Me.txtadvtime.Value
advsplit = AdviseElapsed(currtime, advtime)
Me.txtcurrtime.Requery
Me.txtsplittime.Value = Format(split, "hh:nn:ss")
Me.txtadvintsplit.Value = Format(advsplit, "hh:nn:ss")
If Me.txtsplittime.Value <= "00:02:00" Then
Me.txtsplittime.BackColor = vbYellow
End If
If Me.txtsplittime.Value <= "00:02:10" Then
DoCmd.Restore
End If
End Sub
Function ElapsedTime(currtime As Date, deptime As Date) As Date
ElapsedTime = deptime - currtime
End Function
Function AdviseElapsed(currtime As Date, advtime As Date) As Date
AdviseElapsed = advtime - currtime
End Function
The advtime and advsplit variables aren't supposed to be activated unless the cmd button is clicked. But when I run the Code I'm getting Error 94 "Invalid use of Null". Anyone know a way around it or a fix.
Private Sub Form_Timer()
'Declair the Dimmensions
Dim currtime As Date
Dim deptime As Date
Dim split As Date
Dim advsplit As Date
Dim advtime As Date
'Start the Main Clock after loading the Departure Time
If IsNull(Me.txtdeptime.Value) Then
Exit Sub
End If
If IsNotNull(Me.txtadvtime.Value) Then
Me.txtsplittime.Value = Format(advsplit, "hh:nn:ss")
End If
'Define the Dimmensions
currtime = Me.txtcurrtime.Value
deptime = Me.txtdeptime.Value
split = ElapsedTime(deptime, currtime)
advsplit = Me.txtadvtime.Value
advsplit = AdviseElapsed(currtime, advtime)
Me.txtcurrtime.Requery
Me.txtsplittime.Value = Format(split, "hh:nn:ss")
Me.txtadvintsplit.Value = Format(advsplit, "hh:nn:ss")
If Me.txtsplittime.Value <= "00:02:00" Then
Me.txtsplittime.BackColor = vbYellow
End If
If Me.txtsplittime.Value <= "00:02:10" Then
DoCmd.Restore
End If
End Sub
Function ElapsedTime(currtime As Date, deptime As Date) As Date
ElapsedTime = deptime - currtime
End Function
Function AdviseElapsed(currtime As Date, advtime As Date) As Date
AdviseElapsed = advtime - currtime
End Function
The advtime and advsplit variables aren't supposed to be activated unless the cmd button is clicked. But when I run the Code I'm getting Error 94 "Invalid use of Null". Anyone know a way around it or a fix.