G
Guest
I have code in a field on a form to validate the entry to be not less than
the previous entry. It has been working fine but when I went from 99920 to
100004 the error message displayed. I set a break point and checked the
variables and they had the correct numbers. What is the reason for the error
message displaying?
Here is my code:
Private Sub Odometer_BeforeUpdate(Cancel As Integer)
Dim varPrevOdometer As Variant
varPrevOdometer = DLookup("MaxOfOdometer", "qryLastOdometer")
If Me.Odometer < varPrevOdometer Then
Cancel = True
Me.Odometer.SelStart = 0
Me.Odometer.SelLength = Len(Me.Odometer.Value)
MsgBox _
"The last odometer entered for this truck was " & _
varPrevOdometer & vbCrLf & _
"Please enter an odometer greater than or equal " & _
"to this.", , _
"Invalid Odometer Entry"
End If
Thanks for your help.
the previous entry. It has been working fine but when I went from 99920 to
100004 the error message displayed. I set a break point and checked the
variables and they had the correct numbers. What is the reason for the error
message displaying?
Here is my code:
Private Sub Odometer_BeforeUpdate(Cancel As Integer)
Dim varPrevOdometer As Variant
varPrevOdometer = DLookup("MaxOfOdometer", "qryLastOdometer")
If Me.Odometer < varPrevOdometer Then
Cancel = True
Me.Odometer.SelStart = 0
Me.Odometer.SelLength = Len(Me.Odometer.Value)
MsgBox _
"The last odometer entered for this truck was " & _
varPrevOdometer & vbCrLf & _
"Please enter an odometer greater than or equal " & _
"to this.", , _
"Invalid Odometer Entry"
End If
Thanks for your help.