|
-
January 17th, 2000, 02:00 PM
#1
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
-
January 17th, 2000, 04:24 PM
#2
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
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
January 17th, 2000, 06:36 PM
#3
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|