I asked a week or so ago about calculating time differences and I got help, but I lost my database and I cannot remember how to do this.
I was pointed to a function to calculate the elapsed time between 2 hour fields. Here it is:
Public Function fElapsedTime(vStartTime As Variant, vEndTime As Variant) As String
Dim intHrs As Integer, intMins As Integer
If Not IsDate(vStartTime) Or Not IsDate(vEndTime) Then Exit Function
If vStartTime > vEndTime Then
intMins = DateDiff("n", DateAdd("d", -1, vStartTime), vEndTime)
Else
intMins = DateDiff("n", vStartTime, vEndTime)
End If
intHrs = intMins \ 60
intMins = intMins Mod 60
fElapsedTime = intHrs & ":" & Format(intMins, "00")
End Function
I cannot remember how to call this function. How do I get this field to update? Do I do it in the Control Source of an Unbound field on my form? or in the Visual Basic window under some event?
Thanks.
I was pointed to a function to calculate the elapsed time between 2 hour fields. Here it is:
Public Function fElapsedTime(vStartTime As Variant, vEndTime As Variant) As String
Dim intHrs As Integer, intMins As Integer
If Not IsDate(vStartTime) Or Not IsDate(vEndTime) Then Exit Function
If vStartTime > vEndTime Then
intMins = DateDiff("n", DateAdd("d", -1, vStartTime), vEndTime)
Else
intMins = DateDiff("n", vStartTime, vEndTime)
End If
intHrs = intMins \ 60
intMins = intMins Mod 60
fElapsedTime = intHrs & ":" & Format(intMins, "00")
End Function
I cannot remember how to call this function. How do I get this field to update? Do I do it in the Control Source of an Unbound field on my form? or in the Visual Basic window under some event?
Thanks.
Last edited: