Linked Combos in a subform

O

o wilson

Hello,

I have a Form (Form17) with two linked combo boxes,
cboDiv and cboCostCode.

My rowsource code is:

SELECT CostCodeOrder.DivNo, CostCodeOrder.CostCode & " -
" & CostCodeOrder.ItemDesc FROM CostCodeOrder WHERE
(((CostCodeOrder.DivNo)=Forms!Form17!cboDiv));

It works when Form17 is a stand alone form but I get
prompted for a parameter when Form17 is put into another
form as a subform. The parameter asked for is:

Forms!Form17!cboDiv

What can I do to get cboCostCode to work without a
parameter box?

TIA

Owen
 
S

Sandra Daigle

A subform is not open by itself - it is only open indirectly through the
subform control on the main form. So to reference a control on the subform,
you must also reference the subform control. With the following:

Main Form: named frmMain
subform control: named sfrmSub1
control on the subform: named txtMyControl

then from a query the correct reference to this control would be:

Forms!frmMain.form!sfrmSub1!txtMyControl

Note that 'sfrmSub1' 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
sfrmSub1.
 

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