Reference sub-subform though VBA

G

Guest

I need to reference controls and properties on a subform that is two levels
down from the main form. VBA is on main form is:

Me.SubFormControl.Form.SubFormControl.Form.[control or property]

I get an "Application-defined or object-defined error" message.

Any suggestions?
 
A

Allen Browne

That should work.

Double check the names of the subform controls.
They can be different from the name of the form they contain.

You could try a bang instead of a dot:
Me!SubFormControl.Form!SubFormControl.Form![control]

If it still fails, open the Immediate Window (Ctrl+G), and take it a step at
a time until you confirm each step. Start with:
Forms![MyMain]![SubformControl].Name
and follow it down.
 
G

Guest

Checked all that to no avail. I can make it down as far as
Me.SubFormControl.Form.SubFormControl and retrieve properties, but when I
reference the .Form property I get nothing. I should point out that both the
subform and the subsubform are displayed in Datasheet view (not that that
should make a difference).


Allen Browne said:
That should work.

Double check the names of the subform controls.
They can be different from the name of the form they contain.

You could try a bang instead of a dot:
Me!SubFormControl.Form!SubFormControl.Form![control]

If it still fails, open the Immediate Window (Ctrl+G), and take it a step at
a time until you confirm each step. Start with:
Forms![MyMain]![SubformControl].Name
and follow it down.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mitch Powell said:
I need to reference controls and properties on a subform that is two levels
down from the main form. VBA is on main form is:

Me.SubFormControl.Form.SubFormControl.Form.[control or property]

I get an "Application-defined or object-defined error" message.

Any suggestions?
 
A

Allen Browne

Huh? If the subform is in Datasheet view, how can it contain a sub-subform?

Is this a subdatasheet instead of a subform perhaps?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mitch Powell said:
Checked all that to no avail. I can make it down as far as
Me.SubFormControl.Form.SubFormControl and retrieve properties, but when I
reference the .Form property I get nothing. I should point out that both
the
subform and the subsubform are displayed in Datasheet view (not that that
should make a difference).


Allen Browne said:
That should work.

Double check the names of the subform controls.
They can be different from the name of the form they contain.

You could try a bang instead of a dot:
Me!SubFormControl.Form!SubFormControl.Form![control]

If it still fails, open the Immediate Window (Ctrl+G), and take it a step
at
a time until you confirm each step. Start with:
Forms![MyMain]![SubformControl].Name
and follow it down.

Mitch Powell said:
I need to reference controls and properties on a subform that is two
levels
down from the main form. VBA is on main form is:

Me.SubFormControl.Form.SubFormControl.Form.[control or property]

I get an "Application-defined or object-defined error" message.

Any suggestions?
 

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