Creating a multi-field key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can I use multiple fields withing a table/record to create a key? For
instance, last_name, date, and status combined?
 
Yes you can. I'm assuming that you mean a Primary Key. Highlight all three
fields in design view and the click on the Primary Key button on the tool
bar. If all your existing data is clean (no dupes on nulls) you should not
see an error when you save the table.

Having said that, I don't recommend it. Your foriegn keys will also need to
be these three fields. I recommend making the combination of the three fields
a unique index and using an autonumber field to like to other tables.
 
FROM Allen Brown --
You can ensure uniqueness by creating an index on the combination of the 3
fields that is not the primary key.
1. Open your table in design view.
2. Open the Indexes box (View menu.)
3. On a new row in the indexes dialog, enter a name for the index, and the
first field. Example:
NameDateStatus last_name
4. On the next row, leave the index name blank (becuase it's part of the
same index), and enter just the 2nd field:
Date
5. On the next row, leave the index name blank (becuase it's part of the
same index), and enter just the 3rd field:
Status

6. In the lower pane of the dialog, set Unique to Yes. You can allow Nulls.
7. Save.
 

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

Back
Top