PC Review


Reply
Thread Tools Rate Thread

Creating a multi-field key

 
 
=?Utf-8?B?RFY=?=
Guest
Posts: n/a
 
      24th Jan 2006
Can I use multiple fields withing a table/record to create a key? For
instance, last_name, date, and status combined?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmVycnkgV2hpdHRsZQ==?=
Guest
Posts: n/a
 
      24th Jan 2006
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.
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"DV" wrote:

> Can I use multiple fields withing a table/record to create a key? For
> instance, last_name, date, and status combined?

 
Reply With Quote
 
=?Utf-8?B?S0FSTCBERVdFWQ==?=
Guest
Posts: n/a
 
      24th Jan 2006
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.


"Jerry Whittle" wrote:

> 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.
> --
> Jerry Whittle
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "DV" wrote:
>
> > Can I use multiple fields withing a table/record to create a key? For
> > instance, last_name, date, and status combined?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table question: Creating a new field that calculates thedivision of one data field by another Mike C Microsoft Excel Discussion 4 13th Jul 2009 08:15 PM
Multi-field primary key, no dupes - but only if one field is empty? Ed from AZ Microsoft Access 7 10th Jan 2008 06:49 PM
creating multi value field in a template desi Microsoft Access 0 7th Dec 2007 03:27 AM
Sum one field in multi field query =?Utf-8?B?Q29ubmll?= Microsoft Access Queries 5 18th Jun 2007 10:51 PM
Creating a multiselect field in a form to populate a single field in a table Conni Microsoft Access Forms 1 21st Sep 2004 05:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 AM.