Access 2007 Allows Duplicate Primary Keys

U

UnhappyAggie

I have a table where the SSN is the primary key. I have a form which is used
to add new records. When I enter a duplicate SSN in the form it stores the
record in the table with no error message or other warning. I thought it was
not possible to get duplicate primary keys.

I tried to enter the duplicate key in directly in the table and it was
blocked. I can only create the duplicate when I enter using the form. I
have tried it three time and it happened every time. I viewed the data in
the table and the duplicate was there. I am open to suggestions.
 
K

KARL DEWEY

Is it possible that your form is adding leading spaces or some sort?
Try this simple query to check for duplicates ---
SELECT YourTable.SSN, Count(YourTable.SSN) AS CountOfSSN
FROM YourTable
GROUP BY YourTable.SSN
HAVING (((Count(YourTable.SSN))>1));
 
J

Jason Lopez

Check your index in the table itself. There is a setting that will allow
duplicates of some primary keys as you can have more than one. If the index
is set wrong, that could be the culprit.

Jason
 
J

Jerry Whittle

What is the Record Source for the form? Is it a table or a query?

Open up the table in design mode. Is the little yellow key next to the SSN
field? Is the SSN field a lookup field by chance?
 
R

Rick Brandt

Jason said:
Check your index in the table itself. There is a setting that will
allow duplicates of some primary keys as you can have more than one. If the
index is set wrong, that could be the culprit.

Actually you can have exactly one Primay Key in a table, but that one PK can
consist of more than one field (up to 10 I believe). In that case you're
correct in that each individual field could have duplicates while the
combination of all fields in the key is what won't allow duplicates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top