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!

Key Violation during INSERT INTO 1

Status
Not open for further replies.

NFI

Programmer
Jun 7, 2000
278
GB
Hello,

I'm a bit new to all of this, so the answer here may well be that I'm just doing it wrong :(

I have two tables, both with a primary key field of reqID. The relationship between them is 1 to 1 and, when I try to insert data into them, I get a Primary Key Violation error. I can see why (I think) - a record can't exist in one table without a corresponding record existing in the other, but I can't create a record in either, as it will always throw a key violation...

So what's the logic of this? Can I not have a 1 to 1 relationship between these tables? Can I tell Access to ignore the key constraints temporarily? It seems like a paradox to me :(

Any advice will be gratefully taken,

Thanks,

Paul
 
It is not common to have a one-to-one relationship in Access, usually such data would be held in one table. You can create a query that includes the essential fields for both tables (this must include the primary keys and at least one required field from each table) and it will be updatable. Access will insert a record into each table as the required field is completed.

It is also possible to create a similar set-up with a form and subform - Access will autocomplete the subform key fields based on the Link Child and Link master fields chosen,

 
I see - thanks for that.

I think I was trying too hard to divide up my data and have ended up with a group of tables which could, realistically, be one table...

Maybe I need to re-think my table structure...

Thanks,

Paul
 
That's useful - thanks for that :)

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top