-
ADO Duplicate key
I am a novice using VB6....
I have an ACCESS database setup and a form that updates the database. I am looking for some example code that will help me trap a "duplicate key" error and format the error in a readable format (other than what is normally returned )...
Thank you in advance...
Regards,
Al
-
Re: ADO Duplicate key
Setup an error handler and test for the error number for the duplicate key error...
private Sub UpdateDB()
'declarations
on error Goto Update_Error
'do processing
...
...
...
'exit before the error handling code, so that it doesn't run unless an error occurrs.
Exit Sub
Update_Error:
If Err.Number = (number of duplicate key error) then
MsgBox "You have entered a key value that already exists.", vbInformation, "error"
'do any other clean up or retry the operation with a new value...
End If
End Sub
Hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
-
Re: ADO Duplicate key
Thank you for the quick response...
The Duplicate key error number is a long negative number.. is that the number that I shoudl use or is there a list of error code available somewhere?
Al