Primay Key and Foreign Key

G

Guest

Hello,

Is it possible to make the primary key (which is an auto number) of Table1 a
foreign key in Table2?

Basically I have been asked to make Table1 generate an auto number which
will be used as the primary key. However, Table2 needs to be linked to
Table1. Therefore I need the auto number from Table1 to also be a foreign
key in Table2.

I hope that I have explained my question thoroughly.
 
P

Paul Overway

Yes...it is quite normal to do this. Create the PK in Table1, and then
create an FK of the same name in Table2. For the FK, set the Indexed
property for the field as needed for your application (i.e, Yes (Duplicates
OK) or Yes (No Duplicates). Then create a relationship within the
Relationships windows setting Enforce Referential Integrity and casade
updates/deletes as needed for your application.

If Table2 is the recordsource for a subform that is on a form with Table1 as
recordsource, the FK will be usually be provided automatically to Table2.
In other cases, you may need to provide the FK for Table2 when inserting a
record (if Enforce Referential Integrity is yes and the field is required).
 

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

Top