dbTalk Databases Forums  

Access complains of duplicate key

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Access complains of duplicate key in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David H.
 
Posts: n/a

Default Access complains of duplicate key - 09-10-2007 , 02:30 PM






Our Access 2000 database (a front end to MSSQL2000 data) has two main tables
with a 1-1 relationship. Call them Client and Assessment. (Why? Mostly
just too many fields to fit in a single table.)
The main data entry form has lots of tabs; the first two tabs look at data
in Client, other tabs use both tables.
Users create a new record using a form which automatically creates records
in both, with the same primary key value (ClientID) in each table. The "New
Client" form then closes and opens the main form, and selects the new client.
They then start entering and saving data happily on tabs 1 and 2. At some
point after that (if they continue entering data without closing that record)
they often get this error:
"ODBC call failed. Violation of Primary Key Constraint (PK_Assessment)
Cannot insert duplicate key in Object 'Assessment'." Any ideas why SQL
thinks I'm trying to insert a duplicate key? Any ideas (other than merging
two tables into one) for how to fix it? Thanks!

Reply With Quote
  #2  
Old   
Russell Fields
 
Posts: n/a

Default Re: Access complains of duplicate key - 09-10-2007 , 02:49 PM






David H.

The problem is with the Access 2000 to SQL Server interface and how Access
decides to insert/update the data. I assume that you are using Access's
native ability to update SQL tables rather than coding your own stored
procedure calls. (But I could be wrong.) However, unless you have
explicitly coded the INSERT and UPDATE statements and their controlling
logic you are not in control of this, but Access is.

The error you are getting is on the PK Constraint, which will not happen
unless you attempt to insert a duplicate key. So, SQL Server thinks you are
inserting a duplicate key because Access is doing so.

Your should probably post this to one of the Access newsgroup for a more
helpful answer about how to work around the problem in Access.

RLF

"David H." <davidh (AT) newspostalias (DOT) com> wrote

Quote:
Our Access 2000 database (a front end to MSSQL2000 data) has two main
tables
with a 1-1 relationship. Call them Client and Assessment. (Why? Mostly
just too many fields to fit in a single table.)
The main data entry form has lots of tabs; the first two tabs look at data
in Client, other tabs use both tables.
Users create a new record using a form which automatically creates records
in both, with the same primary key value (ClientID) in each table. The
"New
Client" form then closes and opens the main form, and selects the new
client.
They then start entering and saving data happily on tabs 1 and 2. At some
point after that (if they continue entering data without closing that
record)
they often get this error:
"ODBC call failed. Violation of Primary Key Constraint (PK_Assessment)
Cannot insert duplicate key in Object 'Assessment'." Any ideas why SQL
thinks I'm trying to insert a duplicate key? Any ideas (other than
merging
two tables into one) for how to fix it? Thanks!



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.