Subform Combo box values filtered by form ontrol

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to display list values in a combo box within a subform that
are filtered by a control field in the main form. No matter how I reference
the control filed in the main form, I either get no data displayed in the
combo box or all the items available in the combo box with no filtering. I've
also tried setting up the same control in the subform and that doesn't work
either. I know about how to reference filds on forms and subforms. Please
help!!!
 
Use a row source query similar to this for that combo box:

SELECT *
FROM TableName
WHERE FieldName = Forms!MainFormName!ControlName;

You'll need to requery the subform's combobox whenever you make a selection
in the main form's control. Best to use the AfterUpdate event of that
control, most likely.
 
I just get the same fixed selection of records in the subform combo box no
matter what choice I make in the main form combo box.
 
Hi Banterista,
Could you tell us something more:
1. What is your Combo box's Row Source,
2. Does the subform link to the main form via Link Child Fileds/Link Master
Fields, what is the link ?
3. What number in the Combo box's Column Count/Column Widths ?
etc ...
The more you describe, the more we can help you.
Good luck.
 
Then either you have a design setup signficantly different from what you're
posted so far, or you've entered the row source query's statement
incorrectly, or you are not requerying the subform's combo box in the
AfterUpdate event of the main form's control.
 
1. The combo box row source is [Forms]![frmAccMastBuy]![AccID]. The SQL is
:-SELECT Regions.RegID, Regions.RAccRef, Regions.Region, Regions.RegCode
FROM Regions
WHERE (((Regions.RAccRef)=[Forms]![frmAccMastBuy]![AccID]))
ORDER BY Regions.Region;

2. The link between the forms is [AccID] on the master and [BAccref] on the
child.
3. I have an unbound combobox control on the main form that finds the
account the user requires and the account number is in [AccID]. It is AccID
that drives the filter for the subform population.

Thanks.
 
Sorry for late. I don't know how you can set the combo box row source to :
[Forms]![frmAccMastBuy]![AccID] ?
1. Try change your combo box row source to:
SELECT [AccID] FROM [tblAccMastBuy];
(you may have to change "tblAccMastBuy" to appropriate table/query name.)
2. Make sure to requery the Combo box in the subform after the Combo box in
the main form is updated, e.g: Me.[SubRegions].Form![Combo1].Requery
If you cannot solve it, please tell us more about your Tables, queries,
forms name etc...
Hope this help.
Banterista said:
1. The combo box row source is [Forms]![frmAccMastBuy]![AccID]. The SQL is
:-SELECT Regions.RegID, Regions.RAccRef, Regions.Region, Regions.RegCode
FROM Regions
WHERE (((Regions.RAccRef)=[Forms]![frmAccMastBuy]![AccID]))
ORDER BY Regions.Region;

2. The link between the forms is [AccID] on the master and [BAccref] on the
child.
3. I have an unbound combobox control on the main form that finds the
account the user requires and the account number is in [AccID]. It is AccID
that drives the filter for the subform population.

Thanks.
Khoa said:
Hi Banterista,
Could you tell us something more:
1. What is your Combo box's Row Source,
2. Does the subform link to the main form via Link Child Fileds/Link Master
Fields, what is the link ?
3. What number in the Combo box's Column Count/Column Widths ?
etc ...
The more you describe, the more we can help you.
Good luck.
 
That's great thanks. The requery from the main form control did the trick!

Khoa said:
Sorry for late. I don't know how you can set the combo box row source to :
[Forms]![frmAccMastBuy]![AccID] ?
1. Try change your combo box row source to:
SELECT [AccID] FROM [tblAccMastBuy];
(you may have to change "tblAccMastBuy" to appropriate table/query name.)
2. Make sure to requery the Combo box in the subform after the Combo box in
the main form is updated, e.g: Me.[SubRegions].Form![Combo1].Requery
If you cannot solve it, please tell us more about your Tables, queries,
forms name etc...
Hope this help.
Banterista said:
1. The combo box row source is [Forms]![frmAccMastBuy]![AccID]. The SQL is
:-SELECT Regions.RegID, Regions.RAccRef, Regions.Region, Regions.RegCode
FROM Regions
WHERE (((Regions.RAccRef)=[Forms]![frmAccMastBuy]![AccID]))
ORDER BY Regions.Region;

2. The link between the forms is [AccID] on the master and [BAccref] on the
child.
3. I have an unbound combobox control on the main form that finds the
account the user requires and the account number is in [AccID]. It is AccID
that drives the filter for the subform population.

Thanks.
Khoa said:
Hi Banterista,
Could you tell us something more:
1. What is your Combo box's Row Source,
2. Does the subform link to the main form via Link Child Fileds/Link Master
Fields, what is the link ?
3. What number in the Combo box's Column Count/Column Widths ?
etc ...
The more you describe, the more we can help you.
Good luck.

:

I want to be able to display list values in a combo box within a subform that
are filtered by a control field in the main form. No matter how I reference
the control filed in the main form, I either get no data displayed in the
combo box or all the items available in the combo box with no filtering. I've
also tried setting up the same control in the subform and that doesn't work
either. I know about how to reference filds on forms and subforms. Please
help!!!
 
Back
Top