I made this VBA code in an Access form but I am getting an error when I am at the last record and hit the Command button again I get a Run-Time error 94 invalid use of a null. The code is down below any help will be appreciated. [email protected]


Dim dtIn As Date
Dim dtOut As Date
Dim cClass As Variant
Dim dClass As Variant
Dim tOut
Dim tIn
Dim tTotal




dtIn = CDate([IN]) + CDate([Time In])




dtOut = CDate([Done]) + CDate([Time Done])

If dtOut >= dtIn Then

[Total Time Hours] = Int(DateDiff("n", dtIn, dtOut) / 60)
[Total Time Minutes] = DateDiff("n", dtIn, dtOut) Mod 60
ElseIf dtIn Or dtOut = DateDiff("n", dtIn, dtOut) Then
MsgBox "Invalid Date in Date Out", vbCritical, "Date Out"

On Error GoTo Err_Command52_Click


DoCmd.GoToRecord , , acNext

Exit_Command52_Click:
Exit Sub

Err_Command52_Click:
MsgBox Err.Description
Resume Exit_Command52_Click