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

Problem with Duplicate Values

Status
Not open for further replies.

darrellx

Programmer
Apr 20, 2005
18
US
I have created a very simple inventory program just to keep track of items in stock. I created a subform for inventory transactions within a product form. When I try to input a second transaction for a particular product id I get the following message:

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

Any ideas as to how to fix this or can I even do what I am trying to do.

Can forward copy of file for viewing

Thanks

Darrellx
 
If transactions and products are in separate tables, it could be a relationship problem. In other words, the primary key of the Products table is related to the primary key of the Transactions table. (the 2 primary keys being related creates a 1:1, disallowing additional entries)
If so, remove the relationship and change the primary key field in the Transactions table to a number type (long integer). Add a new Autonumber field to the Transactions table and make it the primary key.
Reconnect the primary key of the Products table to the old primary key of the Transactions table (this will now be a foreign key) This should produce a 1:Many relationship, allowing mulitple entries in the Transactions table for each Product table entry.


Let them hate - so long as they fear... Lucius Accius
 
Sounds like you've set the ProductID as the primary key in the table. Since a Primary Key must be unique, you can have a particular ProductID appearing only once in the table.

You probably need another field such as TransactionDateTime or TransactionNumber and make the primary key a multi-field key consisting of the ProductID and the new field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top