The code looks something like this:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Response = acDataErrContinue
Select Case DataErr
Case 3022
MsgBox "Your custom message here"
Case Else
MsgBox "An error has occurred " & Err.Number & " " & Err.Description
End Select
End Sub