By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,471 Members | 2,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,471 IT Pros & Developers. It's quick & easy.

Supress Default Primary Key Message

P: n/a
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!
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Wed, 3 Aug 2005 20:57:02 -0400, David Boothe <no*@onyourlife.net>
wrote:

Depends on exactly what you're trying to do, but likely you could
write some code in the Form_OnError event.

-Tom.

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!


Nov 13 '05 #2

P: n/a
Br
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
Nov 13 '05 #3

P: n/a
On Wed, 3 Aug 2005 20:57:02 -0400, David Boothe <no*@onyourlife.net>
wrote:

Depends on exactly what you're trying to do, but likely you could
write some code in the Form_OnError event.

-Tom.

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!


Nov 13 '05 #4

P: n/a
Br
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
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.