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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping key validation messages 1

Status
Not open for further replies.

oharab

Programmer
May 21, 2002
2,152
GB
I have set up a key on a table so that the combination of 2 fields must be unique, but not necessarily individually(ie
1,2
1,3
2,2
3,2
will all pass but trying to enter
1,2
again will cause an error)

Is there a way of trapping the error message on a form and display my own, slightly less user intimidating message.

Cheers

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
Want to get great answers to your Tek-Tips questions? Have a look at F
 
Answered it myself, must learn to check the help file. Turns out it's actually quite useful in 2k3!!
Basically I need to use the Form_Error event and handle it from in there.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const conDuplicateKey = 3022
Dim strMsg As String

If DataErr = conDuplicateKey Then
Response = acDataErrContinue
Call MsgBox("You cannot use the same Clip Reference again." _
& vbCrLf & "Please check and try again." _
, vbExclamation, Application.Name)
End If
End Sub


Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
Want to get great answers to your Tek-Tips questions? Have a look at F
 
You may also prevent the error using the DLookUp function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top