A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multiple Keys



 
 
Thread Tools Display Modes
  #1  
Old May 29th, 2007, 08:46 PM posted to microsoft.public.access.tablesdbdesign
Chinny03
external usenet poster
 
Posts: 23
Default Multiple Keys

I am creating a database where my primary key is a panel number. From there
it breaks down into cells. So it is possible for a panel number to be listed
more than once. For example:

Panel number: 111111
cell: 1

Panel number: 111111
cell: 2

How could I set up a table/form so that it is possible to have the same
panel number? Thanks.

  #2  
Old May 29th, 2007, 09:30 PM posted to microsoft.public.access.tablesdbdesign
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Multiple Keys

You can not have multiple keys but you can have a nulti-field key.
Open the table in design view. Click on menu VIEW - Indexes. Add your field
in the grid and give the index a name. Then set it as primary in the window
below.
Then you can have ---
Panel number cell
111111 1
111111 2
111111 3
222222 1
222222 2

--
KARL DEWEY
Build a little - Test a little


"Chinny03" wrote:

I am creating a database where my primary key is a panel number. From there
it breaks down into cells. So it is possible for a panel number to be listed
more than once. For example:

Panel number: 111111
cell: 1

Panel number: 111111
cell: 2

How could I set up a table/form so that it is possible to have the same
panel number? Thanks.

  #3  
Old May 29th, 2007, 09:54 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Multiple Keys

On Tue, 29 May 2007 12:46:02 -0700, Chinny03
wrote:

I am creating a database where my primary key is a panel number. From there
it breaks down into cells. So it is possible for a panel number to be listed
more than once. For example:

Panel number: 111111
cell: 1

Panel number: 111111
cell: 2

How could I set up a table/form so that it is possible to have the same
panel number? Thanks.


Your primary key *CANNOT* be the panel number, for this very reason: it's not
unique!

Instead, select both the panel number field and the cell field in table design
view, and click the Key icon. You'll then have a two-field primary key; either
the panel number or the cell can repeat, but the combination must be unique.

John W. Vinson [MVP]
  #4  
Old July 31st, 2007, 05:42 PM posted to microsoft.public.access.tablesdbdesign
knowshowrosegrows
external usenet poster
 
Posts: 156
Default Multiple Keys

I get the concept of a two key Primary key making a unique identifier. Love
that. When I test my database though and put in a record with identical
primary key fields, the database throws an errors and freezes up. Putting in
records more than once is just the kind of thing that will happen with this
database so, can you tell me the elegant way to have the user notified of the
error and not freeze up so they can change their entry?
--
Thanks


"John W. Vinson" wrote:

On Tue, 29 May 2007 12:46:02 -0700, Chinny03
wrote:

I am creating a database where my primary key is a panel number. From there
it breaks down into cells. So it is possible for a panel number to be listed
more than once. For example:

Panel number: 111111
cell: 1

Panel number: 111111
cell: 2

How could I set up a table/form so that it is possible to have the same
panel number? Thanks.


Your primary key *CANNOT* be the panel number, for this very reason: it's not
unique!

Instead, select both the panel number field and the cell field in table design
view, and click the Key icon. You'll then have a two-field primary key; either
the panel number or the cell can repeat, but the combination must be unique.

John W. Vinson [MVP]

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:14 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.