views:

242

answers:

1

good day

I have successfully (Thanks to much help from stackoverflow) sync'd two combo-boxes on a form.

NEW PROBLEM...

I created a from, with a sub-form. The one combo-box(A) is in the form, while the other(B) is in a sub-from. (combo 'B' must be limited to combo 'A')

ie..(it works when both combo-boxes are on the form, but when the one(combo 'B') is in the sub-form, an err occurs

Query code:


SELECT products.Product_Name FROM Table1 INNER JOIN products ON Table1.Suppliers_of_Customer=products.Company_Name WHERE (((Table1.Suppliers_of_Customer)=[Forms]![Form1].[A]));

Macro code for COMBO 'A':


ACTION Requery
ARGUMENTS B

ACTION SetValue
ARGUMENTS [B], nz(DMin("Product_Name","Query1"),"")


What do i do? Thanks...

A: 

You need to learn how to refer to controls on subforms.

If you have cmbComboBox1 on your parent form and cmbComboBox2 on a subform called MySubForm, from within the main form, you'd refer to them as:

  Me!cmbComboBox1
  Me!MySubForm.Form!cmbComboBox2

From the subform, you'd refer to them thus:

  Me.Parent!cmbComboBox1
  Me!cmbComboBox2

There can be problems with resolving Me.Parent in some contexts, and I haven't a clue if it works in Macros (real Access programmers don't use Macros -- get away from them as soon as you possibly can). In that case, you might have to refer to the parent fully qualified by its name via the Forms collection:

  Forms!ParentForm!cmbComboBox1

But you should try Me.Parent first because that means the subform could be embedded in many different parent forms, as long as they had the same control names.

David-W-Fenton