David Boothe <no*@onyourlife.net> wrote:
is there a way to suppress the standard Access warning when a user
attempts to add a record that violates a unique index/primary key? I
would prefer to have a custom message box...
Thanks!
First find out what the error code is (I can't remember it off hand)
Private Sub Form_Error(DataErr As Integer, Response As Integer)
MsgBox "Error number: " & DataErr
Response = acDataErrDisplay
End Sub
Then change the code to the following and insert the error number you
need.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 1234 Then 'change the code to the one you need
MsgBox "You need a primary key!"
Response = acDataErrContinue 'don't display the default access error
Else
Response = acDataErrDisplay 'diaply the default Access error
End If
End Sub
--
regards,
Bradley
A Christian Response
http://www.pastornet.net.au/response