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
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