Yes, use the Error event of the form to call another generic function to
handle those errors.
Example:
Public Function FormError(frm As Form, DataErr As Integer, Response As
Integer) As Integer
On Error GoTo Err_FormError
'Purpose: Generic Form_Error handler.
'Return: Response.
'Usage: In a form's Error event procedure:
' Call FormError(Me, DataErr, Response)
Dim strMsg As String
Const conDupeIndex As Integer = 3022
Const conFileMissing As Integer = 3024
Const conRelatedRecordRequired As Integer = 3201
Const conRequiredField As Integer = 3314
Const conInvalidType As Integer = 2113
Select Case DataErr
Case conDupeIndex
Response = acDataErrContinue
strMsg = "The record cannot be saved, as it would create a
duplicate."
Case conRelatedRecordRequired
Response = acDataErrDisplay
Case conRequiredField
strMsg = "This is a required field." & vbCrLf & vbCrLf & "Make an
entry, or press <Esc> to undo."
Response = acDataErrContinue
Case conInvalidType
strMsg = "Wrong type of data."
Response = acDataErrContinue
Case conFileMissing
strMsg = "Data file is currently unavailable."
Response = acDataErrDisplay
Case Else
Response = acDataErrDisplay
End Select
If Len(strMsg) > 0 Then
MsgBox strMsg, vbExclamation, "Invalid data"
End If
FormError = Response
Exit_FormError:
Exit Function
Err_FormError:
Call LogError(Err.Number, Err.Description, "FormError()", "DataErr: " &
DataErr)
Resume Exit_FormError
End Function