I have a data-entry form with one bound text field to receive a number from a barcode scanner. The BeforeUpdate event for this field contains code to verify that the ID number scanned is valid:
There is nothing in the "validation rule" for this field, just the above code in BeforeUpdate.
(The error message appears in an unbound text box instead of a msgbox so the user doesn't have to hit enter.)
Everything's fine if a valid number is scanned, but if an invalid number is entered, I get a validation error.
I've tried this with and without the Undo; no difference. I moved the message to display after the cancel & undo to see if Access gets that far before the error, and the message does appear before it errors out.
Why isn't it cancelling?
Any insight is much appreciated!
Joe
Code:
Private Sub barcode_BeforeUpdate(Cancel As Integer)
If DCount("*", "barcode name", "barcode=" & Me!barcode) = 0 Then
Cancel = True
Me!barcode.Undo
Text_Box_for_Message = "I could not recognize your ID card. Please sign in by hand on the paper sign-in sheet."
End If
End Sub
(The error message appears in an unbound text box instead of a msgbox so the user doesn't have to hit enter.)
Everything's fine if a valid number is scanned, but if an invalid number is entered, I get a validation error.
I've tried this with and without the Undo; no difference. I moved the message to display after the cancel & undo to see if Access gets that far before the error, and the message does appear before it errors out.
Why isn't it cancelling?
Any insight is much appreciated!
Joe