Parameter in a subform

G

Guest

Hi,

I hope I can explain this properly.

I've been asked for help on someone else's database. There is a form with a
subform. An unbound field in the subform is a drop down box dependant on
another field. I set the criteria to read - [Forms]![FormName]![FieldName]

When I test this with just the subform open, it works fine. When I try it in
the main form, I get prompted to Enter the Parameter Value
"Forms!FormName!FieldName".

Any help? I feel like I'm forgetting something simple.

Thanks,
 
S

Sandra Daigle

Hi Marc,

You have to reference the control through the main form. Since a subform is
not open by itself it is not a member of the forms collection.

To reference a control on the subform, you must also reference the subform
control. If the subform control is named SubFormName and the control on the
subform is named FieldName then your criteria would be something like this:

forms!MainFormName!SubFormName!FieldName

Note that 'SubFormName' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
'SubFormName' .
 
G

Guest

Hi Sandra,

Thank you so much. You've kept me from going crazy. I had tried
forms!MainFormName!SubFormName!FieldName, but just assumed the sub form name
was the same sub form control name, which it wasn't.

Thanks again!

Marc

Sandra Daigle said:
Hi Marc,

You have to reference the control through the main form. Since a subform is
not open by itself it is not a member of the forms collection.

To reference a control on the subform, you must also reference the subform
control. If the subform control is named SubFormName and the control on the
subform is named FieldName then your criteria would be something like this:

forms!MainFormName!SubFormName!FieldName

Note that 'SubFormName' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
'SubFormName' .


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi,

I hope I can explain this properly.

I've been asked for help on someone else's database. There is a form
with a subform. An unbound field in the subform is a drop down box
dependant on another field. I set the criteria to read -
[Forms]![FormName]![FieldName]

When I test this with just the subform open, it works fine. When I
try it in the main form, I get prompted to Enter the Parameter Value
"Forms!FormName!FieldName".

Any help? I feel like I'm forgetting something simple.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top