custom primary key using multiple fields

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

Guest

I would like to create my own primary key using a concatenation of existing
fields:
eventnumber & date & time.
How do I go about doing this?
Any help is greatly appreciated. Thank you in advance.
 
Why? Access is capable of using a primary key that's comprised of up to ten
separate fields.

Concatenating values into a single field is rarely a good idea.
 
Thank you for your response. Perhaps I'm wording this incorrectly. I would
like to create a primary key (separate field, of course) that is comprised of
data in 3 existing fields: EventNumber, Date, Time. I'm not sure how to go
about doing this.
 
What Doug said.

I'll add that multi-field primary keys can be a PITA to maintain. If you
have a two-field PK, then you need a two-field foriegn key in related tables.

IMHO you are better off using an autonumber as the primary key and making
the two fields a unique index / constraint to prevent duplicates.

One other thing: Date and time should be in just one field. Again IMHO.
 
If you're doing it through the GUI, open the table in Design view and select
all of the fields of interest (using the Ctrl key if they're not
contiguous). Then, click on the Key button on the Button Bar (or select
Primary Key from the Edit menu)
 
Thank you for your response, Jerry.

Jerry Whittle said:
What Doug said.

I'll add that multi-field primary keys can be a PITA to maintain. If you
have a two-field PK, then you need a two-field foriegn key in related tables.

IMHO you are better off using an autonumber as the primary key and making
the two fields a unique index / constraint to prevent duplicates.

One other thing: Date and time should be in just one field. Again IMHO.
 

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