-
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 soke 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 )...
Thnak you in advance...
-
Re: ADO Duplicate Key
put this in the sub where the error occurs
'put this at the top
on error goto ADOerror
'you can write here the rest of the code
exit sub
:ADOerror
if err.number = 'put here the number that the error returns
msgbox "Duplicate key in table" & vbcrlf & err.description, vbokonly, "error " & err.number
end if
-
Re: ADO Duplicate Key
I think this only works when you save your recordset, not with immediate effect
as your control losts its focus.
-
Re: ADO Duplicate Key
You can write a quick SQL Statement to test the value they enter though. do a select statement with the where clause value equal to the value the user entered. if you get something back, then it's a dupliate, if not, then it's okay.
John
John Pirkey
MCSD
www.ShallowWaterSystems.com