Friday, October 22, 2010

How do I link fields from Access tables so that a value automatically comes up in another table?

I would like to link a field (primary key) of the parent table (1,2,3) to match the children in the child table. So if Joe Williams has two children, his unique id is 1 and then in the child table his first child is 1a and second child is 1b. The next parent would be 2 etc. And as I add new students can Access automatically link these fields to create the right ID?



I've tried everything...



THANK YOU!How do I link fields from Access tables so that a value automatically comes up in another table?
Here's what Access will do automatically, but you have to set it up according to the rules:



The child table, while it has its own primary key, must have a field called the foreign key that contains the parent number (forget the 1a, 1b etc, you can list them by birth order using the DOB field which I am assuming is present):



So you have a field called ParentNo as primary key in the parent table, and another field called ParentNo in the children table, called the foreign key.



Then you link the two tables together in the relationships view by dragging the ParentNo field from the parent table to the ParentNo field in the children table. You should also enforce referential integrity.



Then you create a form on table Parent: try autoform for a quick look



The presence of the relationship will cause a form with a subform to be created: the subform will have a blank record, into which you can insert data



Adding children to these fields will ';automatically'; fill in the correct parent number for those children in the children table.



Hope that helps.

No comments:

Post a Comment