Hello,
Thanks in advance for your help.
When a duplicate record is added, I want a custom error message to be displayed, and then the user to be taken to the original record.
Basically if If DataErr = 3022 (error code for duplicates) Then display custom message and go to original record.
I have attached a test database as well as my code below.
Here is the code I have on the Form's On Error event.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
'If an error occurs because of missing data in a required field
'display our own custom error message
Const conErrRequiredData = 3314
If DataErr = conErrRequiredData Then
MsgBox ("All required fields must be filled in")
Response = acDataErrContinue
Else
'Display a standard error message
Response = acDataErrDisplay
End If
'If an error occurs because of a duplicate record.
If DataErr = 3022 Then
Response = acDataErrContinue
MsgBox "This appendix already exists. Press Esc to cancel and then modify your entry."
End If
End Sub