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

Dulicating updating error

Status
Not open for further replies.

lalee5

Technical User
Oct 20, 2002
70
US
How do you go around trying to cancel an update when it is a dulpicating error? Below is detail of my problem:

I have a table in my database that the primary key cannot be duplicate.

When a user try to add arecord with the same product number it gives a long system error,

the problem is in my lost lost focus on the command to add the record I put an error handler to exit the sub but it will not exit the sub. it goes around in cirle with the error message than it finally shuts the program down.


If anyone could share the code to fix this problem I would appreciate it.


thanks Kay
 
add on to my request:

How do you forced the system not to show VB messeges and warnings?


Kay
 
the following code is enough as far as i know to catch the duplication errors. it has worked for me always


private sub cmd1_click()
on error goto errhandling

sqlstatement = "update.(your sqlstatment for updating)....."
conn.Execute sqlstatement, adCmdText
conn.Execute "commit"

errhandling:
if err.number <> 0 then msgbox err.description
end sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top