How to define a unique index over two fields in an Access table?

J

Jarek

I need to define a unique index over two fields in an Access table. The
values of each field can repeat, but a combination of the two fields has to
be unique.

An example:

The following values are ok:

field1, field2
1 1
1 2
2 1
2 2

Now, when I try to insert the following record:
1 2
an error has to occur, because such a combination already exists.

How to do it in Access???
 
D

Duane Hookom

While in table design, view the indexes. Add a name to the first column.
Select one of the fields under Field Name. Set the unique property to Yes.
Select the other field on the next line without providing a name. This will
group the two fields together. Close and save the table. If you records
don't meet the uniqueness then you will get an error.
 
Top