Changing Table properties to not allow duplicates

L

lauralb

When I first built my Database I did not know a lot about Access (still
learning). I want to change it so as not to allow duplicates in one of the
fields of a table. I did a Query to find all the duplicates, deleted them
and am now trying to set the Yes, allow no duplicates but I keep getting an
error that duplicates exist. I have a table with employees listed, then a
table with a list of educational offerings and then a table with the employee
ID and the education ID together to show actual attendance. Any help would
be appreciated.
 
A

Allen Browne

Presumably you have the EmployeeID primary key in your employee table, so
there are no duplicates there. And you would have an EducationID primary key
in your education list table, so no duplicates there. Therefore I presume
the problem is in the 3rd table, where you want the combination of
EmployeeID + EducationID to be unique?

To find the duplicates:
1. Create a query using the 3rd table.

2. Depress the Totals button (toolbar.)
Access adds a Total row the the query design grid.

3. Add EmployeeID into the grid.
In the Total row, accept Group By under this field.

4. Add EducationID to the grid.
Accept Group By under this field too.

5. Add EmployeeID again.
In the Total row, choose Count under this field.
In the Criteria row, enter:

The query till show you the combinations of EmployeeID and EducationID that
occur more than once in the table.

Once you remove the last duplicates, you can open the 3rd table in design
view, select the 2 fields together, and make the combination the primary
key. Alternatively, open the Indexes box (Toolbar), and enter a unique index
on the 2 (that's 2 rows of the dialog, with a name for the index beside the
field on the first row, but leaveing the index name blank beside the field
on the 2nd row.)
 

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

Similar Threads


Top