By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

Access: Populating Foreign Key with Primary Key using Forms

P: 1
Hello,

I am creating a database for everyday use for my company. What I am struggling with is the following:

I have two tables. TABLE A: An AutoNumber is being used for the primary key. I created a form for this table so the information can be entered.

But for each record, there eventually will be an audit (TABLE B). I have a foreign key set up in TABLE 2 which is a number field. What I would like to happen is to create a command button from the form of TABLE A to open a form for TABLE B.

What I am having a problem with is getting my foreign key to populate with the AutoNumber of the primary key in TABLE A, thus always linking the two together.

Any sugggestions?

Thank you!!!
Mar 13 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
Hello,

I am creating a database for everyday use for my company. What I am struggling with is the following:

I have two tables. TABLE A: An AutoNumber is being used for the primary key. I created a form for this table so the information can be entered.

But for each record, there eventually will be an audit (TABLE B). I have a foreign key set up in TABLE 2 which is a number field. What I would like to happen is to create a command button from the form of TABLE A to open a form for TABLE B.

What I am having a problem with is getting my foreign key to populate with the AutoNumber of the primary key in TABLE A, thus always linking the two together.

Any sugggestions?

Thank you!!!
In the OnLoad Event of Table B's form put ...

Expand|Select|Wrap|Line Numbers
  1. Me.[ID Field] = Forms![FormA]![ID Field]
Mary
Mar 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.