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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Using Autonumber as PK?
Does Access have a problem using an autonumber for a PK? I've got 3 tables.
tbl-Parts pk-PartsID - Autonumber PartNumber - Number PartDescription - Text tbl-Universal pk-UniversalID - Autonumber UniversalPartNumber - Number UniversalDescription - Text tbl-UniversalParts fk-PartsID - Number fk-UniversalID - Number I then set up some forms per the instructions on this topic I received last week, basically one form is Parts with a subform Universal, and another form Universal with a subform Parts. My problem is finding a work around because both PartNumbers and UniversalPartNumbers may have duplicates at times and can't be used as the pk. Access doesn't seem to like my setup and my friend told me it was the autonumber as the pk but he couldn't explain why or what I needed to do to work around this. Thank you. |
#2
|
|||
|
|||
Using Autonumber as PK?
Autonumbers are generally used as PK.
Did you set a one-to-many relation between the tables? Click on TOOLS - Relationships and add the tables by clicking on the Show Table icon that is a yellow plus sign with a datasheet. The primary key will be in bold. click on the primary key and drag to the foreign key of the related table. Select Enforce Referential Integerity and Cascade Updates. I see you are using a number field for part numbers. I think you need to use text for this datatype as you will never need to do math (add, subtract, multiply, or divide) these numbers. You can have a problem if there is a dash in the number. "Novice" wrote: Does Access have a problem using an autonumber for a PK? I've got 3 tables. tbl-Parts pk-PartsID - Autonumber PartNumber - Number PartDescription - Text tbl-Universal pk-UniversalID - Autonumber UniversalPartNumber - Number UniversalDescription - Text tbl-UniversalParts fk-PartsID - Number fk-UniversalID - Number I then set up some forms per the instructions on this topic I received last week, basically one form is Parts with a subform Universal, and another form Universal with a subform Parts. My problem is finding a work around because both PartNumbers and UniversalPartNumbers may have duplicates at times and can't be used as the pk. Access doesn't seem to like my setup and my friend told me it was the autonumber as the pk but he couldn't explain why or what I needed to do to work around this. Thank you. |
#3
|
|||
|
|||
Using Autonumber as PK?
No problem, in fact it's quite normal to do that.
-Dorian "Novice" wrote: Does Access have a problem using an autonumber for a PK? I've got 3 tables. tbl-Parts pk-PartsID - Autonumber PartNumber - Number PartDescription - Text tbl-Universal pk-UniversalID - Autonumber UniversalPartNumber - Number UniversalDescription - Text tbl-UniversalParts fk-PartsID - Number fk-UniversalID - Number I then set up some forms per the instructions on this topic I received last week, basically one form is Parts with a subform Universal, and another form Universal with a subform Parts. My problem is finding a work around because both PartNumbers and UniversalPartNumbers may have duplicates at times and can't be used as the pk. Access doesn't seem to like my setup and my friend told me it was the autonumber as the pk but he couldn't explain why or what I needed to do to work around this. Thank you. |
#4
|
|||
|
|||
Using Autonumber as PK?
Thanks for the input/advice. I'll change the PartNumber &
UniversalPartNumber to text, that may have been my whole problem because my numbers do have dashes in them. And yes I have one-to-many relationships between, (tbl-Parts - tbl-UniversalParts) and (tbl-Universal - tbl-UniversalParts) and I have selected Enforce Referential Integerity and Cascade Updates in each relationship. Thanks again to all of you. |
#5
|
|||
|
|||
Using Autonumber as PK?
You probably don't need to enable cascading updates since you're going
to be using autonumbers as surrogate promary keys. However, I would enable cascading deletes to that the deletion of a parent record will delete all of tha related child records, leaving no orphans. HTH -- -Larry- -- "Novice" wrote in message ... Thanks for the input/advice. I'll change the PartNumber & UniversalPartNumber to text, that may have been my whole problem because my numbers do have dashes in them. And yes I have one-to-many relationships between, (tbl-Parts - tbl-UniversalParts) and (tbl-Universal - tbl-UniversalParts) and I have selected Enforce Referential Integerity and Cascade Updates in each relationship. Thanks again to all of you. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Specific "auto numbers" possible? | dl | Database Design | 10 | March 1st, 2006 07:44 PM |
PartNumber can be used as primary key | Kyle | New Users | 14 | March 1st, 2006 04:17 AM |
do all primary keys use autonumber | k | Database Design | 11 | November 20th, 2005 01:23 AM |
Access 2000, autonumber fields | Zyberg74 | General Discussion | 3 | November 17th, 2004 04:24 PM |
Autonumber | Ally H. | General Discussion | 7 | August 27th, 2004 04:51 PM |