Here is typical error handler for a subform as a table:
Public Const cErrCodeValueRequierd = 3162
Public Const cErrCodeDuplicateKey = 3022
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case cErrCodeDuplicateKey
MsgBox "Duplicate records are not allowed!", vbExclamation, "Key violation"
Response = acDataErrContinue
Case cErrCodeValueRequired
MsgBox "Field ""fieldName"" requires data!""
Response = acDataErrContinue
Case Else
MsgBox "Other error. Error code: " & DataErr
End Select
End Sub