Visual Basic Error event arises when a run-time error occurs in Access on
the current form.
Error Event Visual Basic Example:
It is good practice to have an On Error event handler in each
form. In this example we simply trap the error and display a message to
the user.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case 3022
MsgBox "This
field must contain unique values."
Case 3023
MsgBox "put
appropriate error text here"
End Select
Response = acDataErrContinue
End Sub
The response argument can have either of two values:
acDataErrContinue: Ignore the error and continue without displaying the
Microsoft Access error message.
acDataErrDisplay: Display the Microsoft Access error message. This is the
default setting.