Link to home
Start Free TrialLog in
Avatar of Jenkins
JenkinsFlag for United States of America

asked on

Contents of subform based upon combobox value

I have a form (MyForm) with a subform on it that displays certain records from MyTable.

The Record Source of the subform is as follows:

SELECT * FROM MyTable WHERE ((([MyTable].Selected)=False));

As it stands now, when the form is opened, the subform is automatically populated with records resulting from the above Select statement.

In MyTable, there is a field that indicates the batch number of each record.

On MyForm, I have a combobox (MyCombobox) for listing “open batches”

Its row source is as follows:

SELECT [query_Get_Open_Batches].[batch_number] FROM query_Get_Open_Batches;

By the way, in case it matters, the “query_Get_Open_Batches”  query is as follows:

SELECT DISTINCT batch_number
FROM MyTable
WHERE Selected = 0;


What I’m trying to accomplish is when MyForm is opened, rather than have it automatically populated, have it appear empty at first. The combobox (upon form entry/opening should also be empty at this point).

Then, when the user makes a selection from the combobox (which lists the “open” batch numbers), have the subform populated only with records from the selected batch number and only where the “Selected” field value = False (which is already accomplished with the SELECT statement near the top of this question).

So, in summary what I’m trying to do is have the subform populated and repopulated based upon the selected combobox value.   For example, if the user selects “Batch #1” from the combobox, have the subform populated with Batch #1 records (ones where the “Selected” field value = False).  If the user then selects Batch #3 from the combo box, have the records currently displayed in the subfom replaced with Batch #3 records (the ones where the “Selected” field value = False).

I’m just trying to have the subform’s contents be based upon the combobox value.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jenkins

ASKER

Thank you.
You're welcome.  Glad you worked out the syntax error.