Solved Refer to Subform control

Emma35

Registered User.
Local time
Today, 04:03
Joined
Sep 18, 2012
Messages
488
Hi Everyone.....i have a quick question regarding cascading combos. I have two of these on a subform and i'm trying to make a selection in the first which controls what's visible in the second. I have the Rowsource of the second combo set as below but i think i need to reference the parent form also ?. I just get a prompt to 'Enter Parameter Value' when i try to use the second combo.

[Forms]![SubformName]![ControlName]

Thanks a lot
 
Below is the closest one i can find in there to my problem but it doesn't work ?

Me!Subform1.Form!ControlName
 
The subform is the subform control name, not the subform name, which might be different? I like to keep my names different by prefixing it with sfc.
That code is the parent referencing the subform control.
 
It should be something like:
Code:
Forms!ParentFormName.SubformControlName.Form!ControlName
Or simply use:
Code:
[ComboName]
Thanks DBguy the first option worked fine. Got it going now.

Gasman.....yes i was using the subform name and not the control. All ok now thanks
 
Me!Subform1.Form!ControlName
Should be
Me.Parent!Subform.Form!ControlName
OR
the long form that the db Guy suggested.

If your code is running IN the code module of the subform, use the Me.Parent style. If the code is running anywhere else, including in a querydef, then you must use the long form that sarts with Form!Parentfformname.Subformcontrolname.Form!ControlName

Also remember "subformcontrolname" is just that. It is the name of the control that holds the subform which may not be the actual object name of the subform.
 
Surely if the code is running in the module of the subform you would just simply use: Me.ControlName ?
Not when you are referencing a control in the parent form which I'm pretty sure is the topic at hand. Although who knows. I've been answering distracted so I may have lost the thread.
 
Not when you are referencing a control in the parent form which I'm pretty sure is the topic at hand.
Then you wouldn't include the subform in the reference.

You'd use Me.Parent.ControlName.

which I'm pretty sure is the topic at hand.
I'm not sure it is, really.

The OP writes:
I have two of these on a subform and i'm trying to make a selection in the first which controls what's visible in the second. I have the Rowsource of the second combo set as below but i think i need to reference the parent form also ?
Actually, no reference to the parent form or Form! is probably necessary at all.

If both combos are on the subform then the RowSource of the second combo need only reference [NameOfFirstCombo] - it doesn't need to have any idea of any form, parent or even itself. [EDIT: I see DBG already suggested this in Post #4 (y) ]
 
Last edited:

Users who are viewing this thread

Back
Top Bottom