Primary Keys

J

js

Hi,
I'm using Access 2002 and I have a small problem. I can't assign a
Primary Key with an index of YES (Duplicates allowed) I even tried the
Nortwinds database, If I dont touch it, it works fine but if I try to
change the settings I can't go back to having A Primary Key with Yes
Duplicates. Is this a bug or is there a flag thatI have to uncheck?
Thanks
David
 
E

Ed Warren

Your suffering from a minor "conceptual misconception".

By definition the primary key must be unique, it is key, therefore you
cannot have a primary key with duplicates.

Other keys can be either unique or allow duplicates.

Access is keeping you from going there.

Cheers,

Ed Warren
 
D

Douglas J. Steele

You can't. By definition, Primary Keys must be unique. That's the definition
of a Primary Key.
 
J

js

Thanks Ed,
But why oh why in the Nortwinds database does the orders detail table
have a primary key with an index of yes (duplicats allowed) am I missing
something. Im trying to setb up my own order entry with a subform that
takes the autonumber from the main form. Thank you, Ed
David
 
V

Van T. Dinh

In the [Order Detail] Table in NorthWind, you have a two-Field PrimaryKey.
The Fields used are OrderID and ProductID. Basically, it means that the
combination (of OrderID/ProductID) must be unique, i.e., you can cannot
order the same item twice on the same order (since you can simply increase
the quantity).

The Field OrderID *by itself* (which is what you saw) can have duplicate
values as you need to have multiple items / Records for different Product on
the same order.

Note that you can only have ONE PrimaryKey per Table. Thus if you see the
Key symbol in front of more than 1 Field, it is A multi-Field PrimaryKey,
NOT multiple Primary Keys. In the DesignView of the Table, you can open the
Indexes dialog (using the icon with the lightning symbol or the Menu View /
Indexes) and you can see all the Indexes and the PrimaryKey.
 
J

js

Thank you, I see how its set-up now. I won't be able to do that with my
database though since I'm not able to use the quantity field. So what I
basically did was set-up my order detail table without a primary field
nd set it with index yes(duplicates allowed) All the info is going to
be imported into access via notepad. Thanks.
David
 
Top