Reference Subform properties and controls from parent form in MS Access

Introduction

Examples

Parent_form is the name of the top level form [the Parent_form / top level form that subs are on]

Subform_One is the name of the subform CONTROL on Parent_form

Subform_Two is the name of the subform CONTROL on the 1st subform.

 

To refer to a form property, like RecordSource

Design View / function for Parent_form Design View / function for Subform_One
On Parent_form Me.RecordSource Me.Parent.RecordSource
On Subform_One Me!Subform_One.Form.RecordSource Me.RecordSource
On Subform_Two Me!Subform_One.Form!Subform_Two.Form.RecordSource Me!Subform_Two.Form.RecordSource

 

To refer to a control

Design View / function for Parent_form Design View / function for Subform_One
On Parent_form Me!ControlName Me.Parent!ControlName
On Subform_One Me!Subform_One.Form!ControlName Me!ControlName
On Subform_Two Me!Subform_One.Form!Subform_Two.Form!ControlName Me!Subform_Two.Form!ControlName

 

To refer to a control property, like Enabled

Design View / function for Parent_form Design View / function for Subform_One
On Parent_form Me!ControlName.Enabled Me.Parent!ControlName.Enabled
On Subform_One Me!Subform_One.Form!ControlName.Enabled Me!ControlName.Enabled
On Subform_Two Me!Subform_One.Form!Subform_Two.Form!ControlName.Enabled Me!Subform_Two.Form!ControlName.Enabled

 

To refer to a subform control property, like SourceObject

Design View / function for Parent_form Design View / function for Subform_One
On Parent_form N/A N/A
On Subform_One Me!Subform_One.SourceObject N/A
On Subform_Two Me!Subform_One.Form!Subform_Two.SourceObject Me!Subform_Two.SourceObject

 

To refer to a form property, like RecordSource

If you are on Sub2 Not in these forms
On Parent_form Me.Parent.Parent.RecordSource Forms!Parent_form.RecordSource
On Subform_One Me.Parent.RecordSource Forms!Parent_form!Subform_One.Form.RecordSource
On Subform_Two Me.RecordSource Forms!Parent_form!Subform_One.Form!Subform_Two.Form.RecordSource

 

To refer to a control

If you are on Sub2 Not in these forms
On Parent_form Me.Parent.Parent!ControlName Forms!Parent_form!ControlName
On Subform_One Me.Parent!ControlName Forms!Parent_form!Subform_One.Form!ControlName
On Subform_Two Me!ControlName Forms!Parent_form!Subform_One.Form!Subform_Two.Form!ControlName

 

To refer to a control property, like Enabled

If you are on Sub2 Not in these forms
On Parent_form Me.Parent.Parent!ControlName.Enabled Forms!Parent_form!ControlName.Enabled
On Subform_One Me.Parent!ControlName.Enabled Forms!Parent_form!Subform_One.Form!ControlName.Enabled
On Subform_Two Me!ControlName.Enabled Forms!Parent_form!Subform_One.Form!Subform_Two.Form!ControlName.Enabled

 

To refer to a subform control property, like SourceObject

If you are on Sub2 Not in these forms
On Parent_form N/A N/A
On Subform_One N/A Forms!Parent_form!Subform_One.SourceObject
On Subform_Two N/A Forms!Parent_form!Subform_One.Form!Subform_Two.SourceObject

 

Conclusion

Conclusion

 

If you would like to read more about MS Access (Is it a good idea to outsource MS Access?) please read our guide : ‘Outsource MS Access

To read more about MS Access in general, view our ‘What is Microsoft Access‘ post or go to Microsoft.

enqueue scripts
enqueue scripts
enqueue scripts

…We do more, so you can do less 🙂

 

Leave a message and we will be straight back to you!

Pin It on Pinterest

Share This