DLookUp query question

W

Walter

Sorry. I hit enter instead of tab.
This is a repost of a question from 4/15.
I am trying to validate an odometer entry >= to the last entry. I have a
query which returns this result. I have code to retrieve this in the
BeforeUpdate event of the Odometer control. The validation is not working so
I set a breakpoint to check the value of the variable. The value is the same
as the current entry. I thought the query would only select from saved
records. How do I accomplish comparing the present entry to the previous
entry? Here is my code:

Private Sub Odometer_BeforeUpdate(Cancel As Integer)
Dim lngPrevOdometer As Long

lngPrevOdometer = Nz(DLookup("Odometer", "qryLastOdometer"), 0)
If Me.Odometer < lngPrevOdometer Then
Cancel = True
MsgBox _
"The last odometer entered for this truck was " & _
lngPrevOdometer & vbCrLf & _
"Please enter an odometer greater than or equal " & _
"to this.", , _
"Invalid Odometer Entry"
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

How is 869343 less than 869330????? 9
sub or function not defined 4
DMax/DLookup help 3
entry validation 2
Validation incorrect 5
Validation code 4
Report Group Footer DLookUp 0
common code sequence 2

Top