How do you?

Nicolette

Always Learning
Local time
Today, 01:46
Joined
Jun 26, 2010
Messages
178
ok I made it so I can't accidently add the same customer a second time but I was wondering if there was a way to create my own error message instead of the one Access pops up?

I believe it is error code 3022 it reads: The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again
 
Last edited:
ok I'm playing with this and it isn't working I'm not that far into learning VB yet so if you could offer some help it is greatly appreciated.

Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const conErrDuplicateKey = 3022
 
Select Case DataErr
      Case conErrDuplicateKey
      'your Error Message here
      Response = "Oops, This customer already exists!"
 
   Case Else
      ' It's an unexpected error.  Let Access handle it.
       Response = acDataErrDisplay
End Select
End Sub
 
I'm not soure I got you right, it seems like 'Response' variable is not doing anything. Try using Functions (with return values), not Subs.
 
try this slight change

note - you may not need the const line- without checking. I am sure this MUST be an access constant

if this is correct acdataerrcontinue should capitalise. this tells access you have dealt with the error, and it can carry on

Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const conErrDuplicateKey = 3022
 
Select Case DataErr
      Case conErrDuplicateKey
      'your Error Message here

[COLOR="Red"]      msgbox("Oops, This customer already exists!")
      response = acdataerrcontinue
 [/COLOR]
   Case Else
      ' It's an unexpected error.  Let Access handle it.
       Response = acDataErrDisplay
End Select
End Sub
 
Just fyi Nicolette, we've noticed that most of your thread titles aren't descriptive, most of the time they are "how do you". It would be very useful if you called it something more descriptive like for example "Creating customised error message" :)
 

Users who are viewing this thread

Back
Top Bottom