Refer to subSubform

K

kon

I have a subsubform for example
forms!mainmaster!headmaster!master.form
I would like to refer as variable to this subsubform
as I do for forms and controls of the form
varform="forms!mainmaster"
forms!(varform).controls(name)

Can someone please show me how?
Thanks in advance
Kon
 
M

Marshall Barton

kon said:
I have a subsubform for example
forms!mainmaster!headmaster!master.form
I would like to refer as variable to this subsubform
as I do for forms and controls of the form
varform="forms!mainmaster"
forms!(varform).controls(name)


You can not include syntactic elements (e.g. Forms!) in the
string variable. Your simple example above would be:
strMainForm = "mainmaster"
strControlName = "txtName"
Forms(strMainForm).Controls(strControlName)

To go deeper into a subform heirarchy:
Forms(strMainForm).Controls(strSubFormControlName).Form.Controls(strSubSubFormControlName).Form.Controls(strControlName)

Note 1: Controls is the default property of a form object,
so it is optional in most situations. This is equivalent to
the above line:
Forms(strMainForm)(strSubFormControlName).Form(strSubSubFormControlName).Form(strControlName)

Note 2: If you must include the syntactic elements in a
string, you can use the Eval function to retrieve the Value
of the control. E.g.
strRef = "Forms![" & strMainForm & "].Controls![" _
& strSubFormControlName & "].Form.Controls![" _
& strSubSubFormControlName & "].Form.Controls![" _
& strControlName & "].Value"
xx = Eval(strRef)
 

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