Linking subforms

  • Thread starter Thread starter Pret
  • Start date Start date
P

Pret

I have two subforms I'd like to link (main form sets up a meeting, sbfA
selects cases to discuss, then sbfB records details for each case). I've
got the main form and the first subform working; but I can't get the first
and second subforms to link.

I've added a text box to the main form and set its control source as the
primary key in sbfA, intending then to have sbfB's foreign key link to the
text box; sort of a cascading link. I think it's a proper approach.

Problem is, I can't get the master links dialogue to pick up the text box as
part of the main form. Even when I go back and insert the second subform
with a wizard, it doesn't acknowledge the textbox.

Any ideas what's wrong, or alternate approaches? Before you suggest it: I'd
much prefer NOT to nest sbfB within sbfA.

Thanks.
 
There is an example in one of the Northwind sample database Orders forms.
Add a textbox on the main form set it = to:

=Forms!MainFormName!SubformAControlName.Form!PrimaryKey

IOW, use the value of the primary key of the subtable (not the foreign key
which is what is linked to the mainform).

In the LinkMaster/Child fields of the second subform, set the links to the
textbox on the main form. Now as you change records in subformA, you will
stay sync'd up to subformB.
--
Arvin Meyer, MCP, MVP
Free MS-Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Back
Top