Full Version: Can't Reference Parent Source Object
UtterAccess Forums > Microsoft® Access > Access Forms
David92595
Hello,

I am trying to reference a parent subform source object (I'm in a sub sub form) and keep getting Error # 2465. Description Application-defined or object-defined error.

Code:

Select Case Me.Parent.subform_Control_Name.SourceObject

Case "Subform 1" then ...

Case "Subform 2" then ...

End Select

What am I doing wrong????


David92595
azolder
First, are you sure your using the subform control's name? It's not necessarily the same name as the (usual) form.

You're wanting the parent subform's source object? The Source Object is a property of a subform control.
Me.Parent would refer to the parent subform
Me.Parent.Parent would refer tot the parent's parent form/subform.
Me.Parent.Parent!subform_Control_Name would refer to the subform control on the parent's parent.

so
Me.Parent.Parent!subform_Control_Name.SourceObject should refer to the source object of the subform control on the parent's parent.

or maybe you should try
Me.Parent.Parent.Controls("subform_Control_Name").SourceObject
David92595
Thanks azolder!

Me.Parent.Parent!subform_Control_Name.SourceObject worked!

This threw me for a loop. I was referencing the subform_control as Me.Subform_Control with in the subform. It never would have occured to me that I had to go to the Main form and reference from there.

David92595
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.