Unanswered: Define Query Criteria Parameter Value from a List Box
I have a query with the following values in it:
Under Item Classification, I have the following criteria:
Here's what I want to do:
I have a list box on the form that lists all of the Item Classifications currently in the database. When the user clicks a certain Item Classification, I want a report (rptReport1) to open and display only the records that have the selected Item Classification.
So my question is....How can I have the list box automatically fill in the parameter value for the criteria with the user's selection?
One way to do it, is to base rptReport1 on all of the classifications in the database. Then when you open the report with a DoCmd.OpenReport you can filter the report on the [Forms]![frmForm1]![Item Classification] field.
Assuming Item Classification is a string:
If [Forms]![frmForm1]![Item Classification] & ""<>"" then
docmd.OpenReport "rptReport1",,,"[Item Classification]='" & [Forms]![frmForm1]![Item Classification] & "'"
Make sure the Report has filtering turned on. In the Data tab of the Report properties, Filter On.