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

Question on Primary Key violation error number

Status
Not open for further replies.

batteam

Programmer
Sep 12, 2003
374
US
All my Access 2000 .mdb files gave me a 3022 (err.number)error whenever I tried to write a record that duplicated the primary key of a record already in the table.

Now however, in my Access 2000 Projects, (.adp) when I get this primary key violation error, the error number (err.number) is
-2147217873.

Anybody know what happened to 3022? Seems like this
-2147..... number shows up with a lot of errors in .adp files. Any thoughts on this would be appreciated.
 
Put in Error handling and loop through the Errors collection since there may be underlying errors that are more descriptive.

Function SomeFunction()
On Error GoTo ErrHandler

‘’--- some code using the currentproject connection.

Exit Function
ErrHandler:
Dim er As ADODB.Error
Debug.Print " In Error Handler "; Err.description
For Each er In cn.Errors
Debug.Print "err num = "; Err.Number
Debug.Print "err desc = "; Err.description
Debug.Print "err source = "; Err.Source
Next
End Function
 
3022 was an error message from the Jet database engine. Now you are using an ADP with ADO you are getting a SQL Server or ADO error message for the primary key constraint violation which is a different error number.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top