How to set up a name primary key in Access

J

jollimi

In the employee table I am making, the employee name is designed to be
entered into three separate fieldnames namely, lastname, firstname &
middlename. How then do I set up a primary key base on the employee name, in
either "lastname, firstname middlename" or "firstname middlename lastname"
formats?

Thanls for the input.
Joey M
 
K

KARL DEWEY

I recommend you add another field for your primary key such as an autonumber
datatype field.

You can build a unique index that is a combination of your three name
fields. Open the table in design view and click on menu VIEW - Indexes.
Create a name for the index (anything will do) and select the fields. Click
in the row of the first field and then in the window below select Unique.
 
T

TC

To reinforce what Karl & Douglas said: you /do not/ use a person's name
as a primary key. No if's, but's or maybe's! Put that idea right out of
your head.

You need to add a seperate field which is guaranteed to be unique for
every person. That might be, a code that is assigned & entered by the
users, or, an "autonumber" field, which Access automatically sets to
the next available number in that table.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
J

John Vinson

In the employee table I am making, the employee name is designed to be
entered into three separate fieldnames namely, lastname, firstname &
middlename. How then do I set up a primary key base on the employee name, in
either "lastname, firstname middlename" or "firstname middlename lastname"
formats?

Thanls for the input.
Joey M

Just as an example of why I agree with TC and Karl:

I once worked with Dr. Lawrence David Wise, Ph.D., and with Dr.
Lawrence David Wise, Ph.D., in the same company (even the same
building).

Larry was tall, blond, and outgoing; L. David was stocky, dark and
taciturn. Definitely different people, definintely co-workers.

A good primary key should be UNIQUE, STABLE, and SHORT. People's names
fail on all three of these.

John W. Vinson[MVP]
 
T

TC

Many years ago I worked on a pathology system. I remember that we found
a case of several people, all called John Ng (or somesuch), all males,
all with the same date of birth, all living at the same address !!!

"Hi John!"

"Hi, how's it going John?"

"Fine John. How are the Ng's?"

"Fine. How are the Ng's?"

"Great. Oh, there's John. Hi John!"

"Hi. How are the Ng's?"

"Fine! By the way, happy birthday John."

"Thanks. Same to you, John!"

"Are you going over to the Ng's?"

"No - I'm going to the Ng's. Hey - there's John!"

etc. etc. :)

TC (MVP Access)
http://tc.atspace.com
 
T

TC

John said:
A good primary key should be UNIQUE, STABLE, and SHORT.
People's names fail on all three of these.

What if the people themselves, met those three criteria?

(Sorry, I couln't resist it!)

TC
 
M

mnature

TC said:
What if the people themselves, met those three criteria?

(Sorry, I couln't resist it!)

TC
I fit all of these:

I must be unique, because people keep calling me an oddball.

My mother used to ask me if I was raised in a barn. That's similar to a
stable, isn't it?

I'm short. Though, for the life of me, I can't figure out what height has
to do with it . . .
 
J

John Vinson

I fit all of these:

I must be unique, because people keep calling me an oddball.

My mother used to ask me if I was raised in a barn. That's similar to a
stable, isn't it?

I'm short. Though, for the life of me, I can't figure out what height has
to do with it . . .

LOL!!!

Thanks, TC and mnature, I needed a laugh this morning!

Now that I recall, Larry was not short but he seemed pretty stable; L.
David was short but changeable... <g>

John W. Vinson[MVP]
 

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