W
Walter
I have the following code in a TruckID control to
validate the trip date for each truck. If I enter a date
previous to the last date, the MsgBox appears with "The
last trip entered for this truck was on " and the OK
button. Can someone tell me why it is not showing the
date of the last trip? Also it is displaying the MsgBox
even when a valid date is entered. Thanks to Dirk
Goldgar for the code. I have commented the "As Date"
because with it in place, I would get a "type mismatch"
error and the debug would show "dtLastTrip = 12:00:00 AM"
Private Sub TruckID_BeforeUpdate(Cancel As Integer)
Dim dtLastTrip 'As Date
dtLastTrip = DLookup("TripDate", "qryLastTripDate")
If dtLastTrip > Me.TripDate Then
MsgBox _
"The last trip entered for this truck was
on " & _
dtLastTrip & vbCrLf & _
"Please enter a date greater than or
equal " & _
"to this date.", , _
"Invalid Date Entry"
Cancel = True
End If
End Sub
Thanks for your help,
Walter
validate the trip date for each truck. If I enter a date
previous to the last date, the MsgBox appears with "The
last trip entered for this truck was on " and the OK
button. Can someone tell me why it is not showing the
date of the last trip? Also it is displaying the MsgBox
even when a valid date is entered. Thanks to Dirk
Goldgar for the code. I have commented the "As Date"
because with it in place, I would get a "type mismatch"
error and the debug would show "dtLastTrip = 12:00:00 AM"
Private Sub TruckID_BeforeUpdate(Cancel As Integer)
Dim dtLastTrip 'As Date
dtLastTrip = DLookup("TripDate", "qryLastTripDate")
If dtLastTrip > Me.TripDate Then
MsgBox _
"The last trip entered for this truck was
on " & _
dtLastTrip & vbCrLf & _
"Please enter a date greater than or
equal " & _
"to this date.", , _
"Invalid Date Entry"
Cancel = True
End If
End Sub
Thanks for your help,
Walter