Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change default error message

Status
Not open for further replies.

WalkieTalkie

Technical User
Feb 15, 2002
91
NZ
How do I change the default error message that comes up when users try to enter a duplicate primary key? The default error message is "The changes you requested to the table were not sucessful because they would create duplicate values.." blah blah. I want to replace it with something they understand. I've tried putting a message in the form's On Error event but that doesn't stop the default message from appearing. I'd appreciate your help!
 
but that doesn't stop the default message from appearing
Even with the following code ?
Response = acDataErrContinue

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya WalkieTalkie . . .

You can test to see if the new PK exists before saving the value. As an example, try the following in the [blue]Before Update[/blue] event of the PK control. Note: [blue]you![/blue] substitute proper names in [purple]purple[/purple]:
Code:
[blue]   Dim Cri As String
   
   Cri = "[[purple][b]PKName[/b][/purple]] = " & Me![purple][b]PKName[/b][/purple]
   
   If IsNull(DLookup("[[purple][b]PKName[/b][/purple]]", "[purple][b]TableName[/b][/purple]", Cri)) Then
      MsgBox "Duplicate PK Exist!"
      Cancel = True
   End If[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Thanks, PH & AceMan, both help! Sorry for the slow response - had a bit of R&R over Christmas, New Year etc. Happy New Year to you guys!
Cheers
Miranda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top