Linking subforms

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.
 
A

Arvin Meyer [MVP]

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
 

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