correct syntax to refer to a control on a nested subform in Access 2013

jd9913

Registered User.
Local time
Today, 12:52
Joined
Sep 12, 2012
Messages
14
Hi,

I have searched to find the correct syntax to refer to a combo box control on a nested subform. All the examples I've found Access 2013 will not recognize or find the appropriate control.

I have a parent form called IncidentDetails. On that form I have a control called ctrlLogDetail. Within that control is a form called sfrm_LogDetail. On sfrm_LogDetail, I have a control called ctrlType which houses a form called sfrmType. On sfrmType, I have a combo box called cboType. I need to be able to place the cboType choice into a query to filter records for another combo box on that same form. the query works appropriately when I have sfrmType open, however as soon as I try to call the query from the IncidentDetails form, Access cannot find the cboType control.

I've tried multiple variations of the syntax to call to cboType that I've found online. I found a very helpful reference from BTA Development: however the syntax there will NOT work in Access 2013.

Does anyone know what the appropriate syntax would be to get to my control within my 3 deep nested subform? I'm working Access 2013 and won't have a choice regarding Access versions.

Thanks

Jennifer
 
Create a textbox. In its ControlSOurce property click on the ellipses ... and using the Expression Builder navigate to the control in question on the relevant (subsubsub)form. Double-click the Value or click Paste button (if any) and now you have a syntactically correct reference
 
Thank you for replying. I've tried expression builder--it does not work. I can get to the control on my second subform for the 3rd subform but not any levels below that. Access just won't show any controls located in subforms beyond the second level. So I need to have the syntax written out. The default values/helper fields that pop up as I'm typing in the query will only go through to the 2nd level.

This is the code I have in my query:

[Forms]![IncidentDetails].[Controls]![CtrlLogDetail].[Form].[Controls]![sfrmType].[Form].[Controls].[cboType]

Access helps me get to sfrmType, but beyond that I'm guessing based on stuff I've read. However nothing I've tried works, Access still can't find cboType when I start in the IncidentDetails (parent) form.

Any help is appreciated.

Thanks.
 
I would guess that sfrmType is the name of the SourceObject of the subform control but not the name of the control itself. You must use the subformcontrol's name.

BTW It is not necessary to include [Controls] in the reference because it is the default collection of the form.
 
Hi,

Here's how I've changed the syntax. After trying 10 or so iterations, I finally got the query to function.

[Forms]![IncidentDetails]![CtrlLogDetail].[Form]![ctrlType].[Form].[cboType]

IncidentDetails = main form
ctrlLogDetail = 2nd subform control
ctrlType= 3rd level subform control
cboType = control on the 3rd level subform.

Thank you all for your assistance.
 

Users who are viewing this thread

Back
Top Bottom