Multiple subforms on a form.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to creat a from with 2 subfroms. The first links directly to the
main form, the second links to the first subform. I have created the 2
subforms, and am able to nest the second subform into the first, with the
correct data expanding out when I click on a record. I would however rather
have both forms in the main screen and be able to click on the record in the
first subform and show the corresponding data in the second subform. I have
tried to do this but all records show up, not just the ones that I need. The
northwind database does this with their orders form but I can't work out how
- please help
 
Artstitches said:
I am trying to creat a from with 2 subfroms. The first links
directly to the main form, the second links to the first subform. I
have created the 2 subforms, and am able to nest the second subform
into the first, with the correct data expanding out when I click on a
record. I would however rather have both forms in the main screen
and be able to click on the record in the first subform and show the
corresponding data in the second subform. I have tried to do this
but all records show up, not just the ones that I need. The
northwind database does this with their orders form but I can't work
out how - please help

You need to set the MasterLink property of the second subform so that it
references the first subform's matching field(s). It is the entries in
MasterLink and ChildLink that control the filtering and the automatic
propogation of key fields on new records.
 
I thought that that was what was missing, but I don't how. Can you help with
what I should put into those fields? (I should mention that I'm relatively
new to Access and using Access 2003)

Sophie
 
Artstitches said:
I thought that that was what was missing, but I don't how. Can you
help with what I should put into those fields? (I should mention
that I'm relatively new to Access and using Access 2003)

First place a TextBox on the main form with a ControlSource of...

=FirstSubFormControlName.Form.FieldName

....where FieldName is the name of the field that links the first subform to the
second. You should find that as you navigate in the first subform that this
control displays the value of that linking field in the first subform.

Once that is verified you can set the MasterLink property of the second subform
to the name of this TextBox. That is one of the secrets to subforms. The
ChildLink property must be the name of a *field* in the subform, but for the
MasterLink the name of a control works just fine (even an unbound one). Don't
try to use the builder to enter the MasterLink property as that will only offer
field names as choices for the MasterLink. Just type the name of the TextBox
directly into the property box.

Once you verify that the second subform is correctly tracking the current record
in the first subform you can make the TextBox on the main form hidden.

If the link between the two subforms requires more than one field, then just
repeat the above for as many fields as you need (one TextBox per field).
 
Still having trouble....

when I input the information I get a message that says " the expression you
entered contains invalid syntax.. you may have enetered an operand without an
operator"

I am entering into the control source box of the textbox:

=CI Action subform.CI Request form.CIActionID

Where - CI Action subform - is the name of my first subform
- CI Request form - is the name of my main form
- CIActionID - is the name of the linking field between the 2
subforms.

Could it be that my form names and field names have spaces? Or am I
entering the Control Source incorrectly?
 
PROBLEM SOLVED!!!!!

I removed the spaces from the field names and form names and that fixed the
expression error. Then I did some fiddling with the expression until I
stumbled on the correct one. The right control source is...

=CIActionssubform.Form!CIActionID

where - CIACtionssubform - is the first subform
- CIActionID - is the field I want to link.

I was replacing the word form with the form name - which was wrecking things.

Thanks for your help!!!
 
Back
Top