Access Table Unique Record

L

les

In an Access table, I can easily designate a field as
unique so that 2 records can not have the same data in
that field. How can I specify that records be unique
based upon 2 fields?
 
T

Tim Ferguson

In an Access table, I can easily designate a field as
unique so that 2 records can not have the same data in
that field. How can I specify that records be unique
based upon 2 fields?

Use the Indexes window: in the table design window, click the little button
that looks like a lightning strike (or choose View | Indexes).

In the grid, find an empty row and put a name (any name: for example
idxNameAndAge or whatever) in the first column. Now set the properties in
the lower pane: Primary (no), Unique (yes), Ignore Nulls (whatever). Now go
back to the upper pane in the second column, starting in the same row, pick
the first field to be indexed, then below that choose the next field and so
on. This is what mine looks like:

OtherKey OName Ascending
Age Ascending
PrimaryKey IndexID Ascending

which defines two indexes. Not intuitive to begin with, but easy enough to
use once you get used to it.

Don't forget that if you are indexing a table with data in it, they must be
unique before you start... Otherwise it won't error out until right at the
end.

Hope that helps


Tim F
 
D

Douglas J. Steele

In Design mode, select both fields, then click on the Key icon. That'll make
both fields combined the Primary Key for the table. You can select up to 10
fields.
 

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