Error Msg 'Duplicate Values in Index, Primary Key or relationship'

access7

Registered User.
Local time
Today, 10:10
Joined
Mar 15, 2011
Messages
172
Good afternoon

I would be extremely grateful if anyone gets the chance to look into the following error for me... (All based on Frm_Company on the attached db).

The following error occurs when leaving the top subform (SubFrm_Address) and entering the next sub form (SubFrm_Contacts).

'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

The annoying thing is I think I understand the message and what is happening but I have no clue how to stop it from occurring. When I enter the sub form from the main form the primary key is set (sets as soon as I have entered text into the first field). This is set to Index 'No Duplicates' in the Tbl_Company (which it needs to be as each company needs a unique ref).

On entering data into the fields on the sub form (which has the same record source as the main form, Qry_Company), I believe it then tries to create the key again?? I'm not sure why? I'm wondering whether it could have something to do with the record sources for the forms? I have the main form running off a query (Qry_Company) and the others from either the same query or a different table....

I am still fairly new to all this and I have to admit relationships are still something I am trying to get my head around .... could any point me in the right direction or explain where I am going wrong?? I hope I have explained it well enough and that someone can make some sense out of what I have said :)

I have posted a similar thread already earlier today however I think it is more appropriate in the 'Tables' section now rather than 'Forms'... so apologies if you have already read my previous post.
 

Attachments

You appear to be attempting to create a new record with the same primary key as an existing record.

This may be an issue with your tables Primary Key and a Utility may be required to fix this.

Have you tried manually adding a new record to the table ?
Open the table when you add a new record it should immediatley display the new primary key. You can see if this is a duplicate a duplicate and this means you will need to run the utility.

This link should assist.
http://allenbrowne.com/ser-40.html
 

Users who are viewing this thread

Back
Top Bottom