How to setup a name primary key in Access

G

Guest

In the employee table that I just started, the employee name is designed to
be entered into three separate fields namely, lastname, firstname,
middlename. How then do I setup a primary key base on the full employee name
in either "lastname, firstname middlename" or "firstname middlename lastname"
formats?

Thank the input.
 
D

Douglas J. Steele

Name is seldom a good choice for a primary key.

First of all, even having first, middle and last names isn't always
sufficient to ensure uniqueness.

Secondly, how do you handle name changes?

The answer to your question, though, is that you can have up to 10 separate
fields in a single index. To have multiple fields in the primary key, simply
highlight those fields you want, then click on the Key icon.
 
P

Pat Hartman\(MVP\)

Another reason to not use name as the primary key is that there are people
who don't have a middle name. Primary keys REQUIRE non-null values in all
fields. It is better technique to use an autonumber as the primary key and
then make a unique index with the three name component fields. That will
prevent duplicates but indexes allow component fields to be null so a
missing middle name wouldn't cause a problem.
 

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