Referencing subform using string

G

Guest

Hi

I have a form which has a subform on it which in turn has severl subforms on
it, i want to change the record on each of the nested subforms using a piece
of code. This was easy when all the subforms were just on the main form i
used GoToControl then GoToRecord Next, but this no longer works as the nested
subforms are controls on the main form, i wanted to use somethin like this
but can't get it to work exactly

Forms![Frm_View Detailed]!Forms ("" & formname & "")
GoToRecord Next.

where formname is a string with the form name then wants to change. Could
any1 please help me out as this is a major stumbling block :(? Any help will
be greatly appreciated.

Cheers

Danny
 
G

Guest

Hi Sorry the code i wrote was slightly wrong this is what i am trying to do

Forms![Frm_View Detailed]![Frm_View Detailed Main Sub].Forms ("" & formname
& "")

I want to reference a subform of a subform using a string
 
V

Van T. Dinh

There no such collection "Forms" of a Form so your expression won't work ...

Try something like:

Forms![Frm_View Detailed].Controls("1stLevelSubformControlName").Form.
Controls("SecondLevelSubFormControlName")

***Note: You need to use the name of the SubFormCONTROL (for both levels),
NOT the name of the Form being used as the Subform (more accurately, being
used as the SourceObject of the SubformControl).

If you have the name of the 2ndLevelSubformControl stored in a variable, you
can use:

Forms![Frm_View Detailed].Controls("1stLevelSubformControlName").Form.
Controls(YourVariableName)

For more details, see The Access Web:
http://www.mvps.org/access/forms/frm0041.htm

--
HTH
Van T. Dinh
MVP (Access)



Daniel Lees said:
Hi Sorry the code i wrote was slightly wrong this is what i am trying to
do

Forms![Frm_View Detailed]![Frm_View Detailed Main Sub].Forms ("" &
formname
& "")

I want to reference a subform of a subform using a string

Daniel Lees said:
Hi

I have a form which has a subform on it which in turn has severl subforms
on
it, i want to change the record on each of the nested subforms using a
piece
of code. This was easy when all the subforms were just on the main form
i
used GoToControl then GoToRecord Next, but this no longer works as the
nested
subforms are controls on the main form, i wanted to use somethin like
this
but can't get it to work exactly

Forms![Frm_View Detailed]!Forms ("" & formname & "")
GoToRecord Next.

where formname is a string with the form name then wants to change.
Could
any1 please help me out as this is a major stumbling block :(? Any help
will
be greatly appreciated.

Cheers

Danny
 

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