Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing One Time with another.

Status
Not open for further replies.

nwprog

Technical User
Nov 19, 2007
24
US
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.
 
Haven't had my coffee yet, and so can't get my head wrapped around all your code, but in VBA

If IsNotNull(Me.txtadvtime.Value) Then

should be

If Not IsNull(Me.txtadvtime.Value) Then

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks for the input. This one is solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top