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!

Trap an ODBC Call fail error

Status
Not open for further replies.

UHNSTrust

Technical User
Dec 2, 2003
262
GB
I have my tables set up so that a client can only have one of any particular product.

My front end on Access throws up an error about a violation of the primary key when a user attempts to add the same thing for a second time. However, I want to be able to trap the error and provide a custom message and then undo.

I don't know where the current generic error message is being raised from.

Can anybody help point me in the right direction?

Thanks in advance.
Jonathan
 
The current error is coming from the database engine itself (Jet if you're using an Access back end).

Best way to trap this is to use a BeforeUpdate event on your input forms to check the existence of a primary key value with the user entered data and display an error message (and set Cancel = True) if a record exists with that value.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top