How to define combination of fields as a non duplicate combination.

Fritz Paul
Fritz Paul used Ask the Experts™
on
I have a table with some fields. Two of them are Nr (string) and Anno (integer). Each of these two may exist as duplicates, but the combination of any two may only exist once. Is there a way to define the table to ensure that?
(The reason is that Nr refers to a customer and Anno refers to a year and each customer may only occur once each year.)
Thanks.
SShot of table design
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Remote Training and Programming
Top Expert 2015
Commented:
Make a Unique Index on multiple fields:

1. go to the Design view of the table
2. make a unique index on the first field
-- click on the field
-- set Indexed in bottom pane to Yes (No Duplicates)
3. open the indexes window (lightening bolt icon on the Design ribbon)
4. in the second column, the field column, add a second field to the same index by filling out the next row.
 - The first column of the next row will be blank
5. if necessary, add a third field the same way

If you want some of the fields in the index to be allowed to not be filled out then set Ignore Nulls to Yes (in addition to Unique is Yes) in the properties in the Indexes window -- this way, the combination will only be tested if all fields have values.

if you need more explanation for any of the instructions, please ask

Author

Commented:
Thanks. That was so quick and sooo helpful
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and Programming
Top Expert 2015

Commented:
you're welcome ~ happy to help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial