Reference sub-subform though VBA

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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?
 
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?
 
Back
Top