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)