The best way to link subforms to main forms?

K

Kjell Harnesk

I have a database with several tables, most of them are related to a "main"
table with a field ProjectNumber. What is the best/correct way to link
subforms based on the other tables to the main form wich is based on the
"main" table? I want the subforms to update when I change ProjectNumber on
the main form.
 
T

tina

each subform control has LinkChildFields and LinkMasterFields properties.
set the properties to the names of the foreign key/primary key fields
(respectively) that link the subform's underlying table to the main form's
underlying table.

hth
 
J

John Vinson

I have a database with several tables, most of them are related to a "main"
table with a field ProjectNumber. What is the best/correct way to link
subforms based on the other tables to the main form wich is based on the
"main" table? I want the subforms to update when I change ProjectNumber on
the main form.

Depends entirely on how the Tables displayed on the form and subform
are related. If the mainform is based on your Projects table, and the
Subform (or subforms) on tables related one-to-many to the Projects
table, using the ProjectNumber as the foreign key, then simply set the
Subform's Master/Child Link Field to ProjectNumber. Some subforms
might be based on other tables with different relationships - but in
any case, the Master link field should be the field (or fields, for a
multifield key) constiting the "one" side table's link, and the Child
Link Field the corresponding field(s) in the related table.

Note that the subforms won't "update" in the sense of changing the
values stored on disk - but they will navigate to the related records
already stored on disk; and if you add a new record on a subform it
will automatically "inherit" the mainform's value of the linking
field, as the Child Link Field values will be filled in automatically
with the current record's Master Link Field.

John W. Vinson[MVP]
 

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