G
Guest
I am trying to verify an odometer entry. If this entry is less than a
previous, I want to be able to accept or redo the entry. I am trying to
combine two sets of code to accomplish this but I am having problems getting
it to work. The problem is in the strMessage. Here is my code:
Private Sub ValidateOdometer()
'verify that odometer entry is correct
Dim varPrevOdometer As Variant
Dim varPrevDate As Variant
varPrevOdometer = DLookup("MaxOfOdometer", "qryLastService")
varPrevDate = DLookup("ServiceDate", "qryLastService")
If Me.Odometer < varPrevOdometer Then
Dim ctrl As Control
Dim strMessage As String
Set ctrl = Me.ActiveControl
strMessage = "The last service for this unit was on" & vbCrLf & _
varPrevDate & " at " & varPrevOdometer.vbCrLf & _
"Are you entering this out of order?"
If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
Response = acDataErrAdded
Else
ctrl.Undo
End If
Else
Response = acDataErrContinue
ctrl.Undo
End If
End Sub
Thanks for your help!
previous, I want to be able to accept or redo the entry. I am trying to
combine two sets of code to accomplish this but I am having problems getting
it to work. The problem is in the strMessage. Here is my code:
Private Sub ValidateOdometer()
'verify that odometer entry is correct
Dim varPrevOdometer As Variant
Dim varPrevDate As Variant
varPrevOdometer = DLookup("MaxOfOdometer", "qryLastService")
varPrevDate = DLookup("ServiceDate", "qryLastService")
If Me.Odometer < varPrevOdometer Then
Dim ctrl As Control
Dim strMessage As String
Set ctrl = Me.ActiveControl
strMessage = "The last service for this unit was on" & vbCrLf & _
varPrevDate & " at " & varPrevOdometer.vbCrLf & _
"Are you entering this out of order?"
If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
Response = acDataErrAdded
Else
ctrl.Undo
End If
Else
Response = acDataErrContinue
ctrl.Undo
End If
End Sub
Thanks for your help!