Full Version: Refencing a text control in nested subforms
UtterAccess Forums > Microsoft® Access > Access Forms
harua
I have a subform C which is on a tab of subform B where subform B is a subform of form A. On subform C I have an unbound text control called FilterValue in the form header. Subform C is a multirecord subform. The record source for subform C reads 'select * from tblC where col1 = Forms!formA!subformB!subformC!FilterValue;' I can't seem to get the syntax right in the recordsource. appreciate any help.
Alan_G
Try
Select * from tblC where col1 = Forms!formA!subformBControlName.Form!subformCControlName.Form!FilterValue
Have a look here for info on referencing subforms/reports
harua
Thanks Alan, I wil try this syntax. Harry
harua
Alan,
looked at the reference on subforms/reports you gave me. It was very helpful. I tried the syntax, but still can not get it to work, and it is driving me crazy! The actual syntax I'm using is
SELECT * FROM nfx_dcr_artificial_lift where dcr_type = Forms!frm_dcr!subfrm_dcr.Form!frm_dcr_artificial_lift.lifttypefilter;
I have this coded in the recordsource for subform2 which is named frm_dcr_artificial_lift. Again, the source object is a combo box called lifttypefilter. It is located in the header of this multirecord subform. If you have any ideas what else to try, let me know. Thanks, Harry
Alan_G
You're just got a bit missing........try changing it to
!--c1-->
CODE
SELECT * FROM nfx_dcr_artificial_lift where dcr_type = Forms!frm_dcr!subfrm_dcr.Form!frm_dcr_artificial_lift.Form!lifttypefilter;

Note that subfrm_dcr and frm_dcr_artificial_lift need to be the names of the subform controls and not the names of the actual forms that are being used as subforms
harua
Alan,
Y
Your syntax didn't work, but perhaps I am confusing the form names with the subform control names. If I click on the outline of the subform with the properties window displayed, I see the Source Object followed by the link master and link child properties. Is the source object the same as the subform control name? This is what I am using. These are the form names also as I look at the form names in the forms window. Specifically, where do you find the subform control name? Thanks, Harry
Alan_G
You find the subform control name by selecting the control (click the outline as you are doing) and look in the Other tab of the properties window. When you put a subform onto a form, Access tries to be helpful and calls the control the same name as the source object (which will probably be the same name as the actual stand alone form). First thing to do is to change the name of the subform control to something else.
So, for example, your actual form that you're using as a subform is called subfrm_dcr. Change the name of the subform control (think of it as a sort of 'container' that 'holds' the actual form) to something like subDCR. That's then the name that you use in your code....
Make sense....?
harua
Alan,
You make perfect sense. With your explanation, I discovered that subform2 did have a control name different from the form name. I made the appropriate change in the syntax and it worked like a champ. Thanks so much for your help! Harry
Alan_G
You're very welcome - glad you got it working sad.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.