W
Walter
I am trying to validate an odometer entry >= the last entry for this truck.
From what I gather, I can't use DMax because the truck number for the
criteria is in a different table. I've created a query to return the last
odometer and tried to use DLookup to get the result. The error message shows
"?followed by a square" for what the last odometer was. Can someone tell me
how to accomplish this? Here is the code I have in the BeforeUpdate event.
Private Sub Odometer_BeforeUpdate(Cancel As Integer)
Dim varPrevOdometer As Variant
varPrevOdometer = DLookup("Odometer", "qryLastOdometer")
If Me.Odometer < varPrevOdometer Then
MsgBox _
"The last odometer entered for this truck was " & _
DLookup("Odometer", "qryLastOdometer") & vbCrLf & _
"Please enter an odometer greater than or equal " & _
"to this.", , _
"Invalid Odometer Entry"
End If
End Sub
From what I gather, I can't use DMax because the truck number for the
criteria is in a different table. I've created a query to return the last
odometer and tried to use DLookup to get the result. The error message shows
"?followed by a square" for what the last odometer was. Can someone tell me
how to accomplish this? Here is the code I have in the BeforeUpdate event.
Private Sub Odometer_BeforeUpdate(Cancel As Integer)
Dim varPrevOdometer As Variant
varPrevOdometer = DLookup("Odometer", "qryLastOdometer")
If Me.Odometer < varPrevOdometer Then
MsgBox _
"The last odometer entered for this truck was " & _
DLookup("Odometer", "qryLastOdometer") & vbCrLf & _
"Please enter an odometer greater than or equal " & _
"to this.", , _
"Invalid Odometer Entry"
End If
End Sub