prevent standard message for data entry form

rsbutterfly16

Registered User.
Local time
Yesterday, 19:28
Joined
Jun 5, 2006
Messages
77
hi guys i have a code to prevent the standard error message for duplicates in my data entry form but for some reason is not triggering. i keep having the Standard Microsoft Access Error message, when trying to enter a duplicate key value.

this code has worked in my other forms with no problems, that is why i am not sure why it only works when i click on the x button to close the form. this is a data entry form only. My form has a save button and a close button but when i pressed those buttoms the standard message comes out.

this is my code:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3022 Or DataErr = 2601 Or DataErr = 3146 Then
'Display error message
MsgBox "You can't add the same Customert"
'prevent the standard error message from showing
Response = acDataErrContinue
DoCmd.RunCommand acCmdUndo
DoCmd.SetWarnings False
Else
Response = acDataErrDisplay
End If




DoCmd.SetWarnings True

End Sub


help please
 

Users who are viewing this thread

Back
Top Bottom