How to setup and read data from nested subforms

M

magicdds-

I want to set up the following nested subforms:

Main - has a field "OrderID"
subform1 - has a textbox "Name1" & Field "orderID" & "OrderID1"
subform2 - has a textbox "Name2" & Field "OrderID1" & "OrderID2"
subform3 - has a textbox "Name3" & Field "OrderID2"

Subform1 is linked Child & Parent with "OrderID"

To reference "Name1" I do the following:
X = Forms!Main!Subform1.Form!Name1
or
Forms!Main!Subform1.Form!Name1.Visible = true

My Questions are?
1) What do I put in the Link Parent and Link Child property for subform2 and
subform3?

2) How do I write code to reference Name2 (on subform2) and how do I
reference Name3 (on subform3) like I did above to reference Name1 (on
subform1)?

I appreciate any help with this.
Thanks,
Mark
 
D

Douglas J. Steele

Assuming I'm interpretting correctly that subform2 is a subform on subform1
and that subform3 is a subform on subform2, you'd refer to controls on them
as

Forms!Main!Subform1.Form!Subform2.Form!Name1

and

Forms!Main!Subform1.Form!Subform2.Form!Subform3.Form!Name1

However, depending on how you added the forms as subforms, be aware that the
name of the subform control can be different than the name of the form being
used as a subform. It's the name of the subform control you need to use, not
the name of the form being used. See
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web" for more on
this topic.

Since Subform2 is a subform on Subform1, what you put in the Link Parent
property must refer to controls on Subform1 and what you put in the Link
Child property refers to controls on Subform2. Similarly, since Subform3 is
a subform on Subform2, what you put in the Link Parent property must refer
to controls on Subform2 and what you put in the Link Child property refers
to controls on Subform3.
 

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