"Select All" in combo box for query

B

buscher75

I have an unbound form created to run a query/report. I have a combo box
that selects the department to be queried and I want to add "All Plant" to
the list of departments. This way a report can be generated by department or
plant wide. I've added "All Plant" to the list but do not know how, when
selected, to convert the words to a blank field within the query. Thanks in
advance for the help.
 
K

KARL DEWEY

Try this in criteria --
Like IIF([Forms]![YourFormName]![CpomboBox] <> "All Plant",
[Forms]![YourFormName]![CpomboBox], "") & "*"
 
B

buscher75

I added your statement to the criteria of the department field in the query.
I can pull individual departments but not the "All Plant" I believe the way
I added all plant to the combo box has something to do with it. The combo
box's row source is linked to a reference table listing all of the
departments. To simplify, I added All Plant as a record. In my head this
made since; then, if needed, the department representative could also be
defined from the same table.

Not sure what to do here. I guess I do not know how to add "All Plant" to
the combo box if it is not listed in the record source.


KARL DEWEY said:
Try this in criteria --
Like IIF([Forms]![YourFormName]![CpomboBox] <> "All Plant",
[Forms]![YourFormName]![CpomboBox], "") & "*"


--
KARL DEWEY
Build a little - Test a little


buscher75 said:
I have an unbound form created to run a query/report. I have a combo box
that selects the department to be queried and I want to add "All Plant" to
the list of departments. This way a report can be generated by department or
plant wide. I've added "All Plant" to the list but do not know how, when
selected, to convert the words to a blank field within the query. Thanks in
advance for the help.
 
J

John Spencer

Better would be (Then you don't get unexpected results if you have department
names like "Shoes" and "Shoes-Accessories".

Like IIF([Forms]![YourFormName]![ComboBoxName] <> "All Plant",
[Forms]![YourFormName]![ComboBoxName], "*")

Or if the Department could ever be null then the following entered into the
criteria "cell" would return all records whether or not Department was null.

=[Forms]![YourFormName]![ComboBoxName] OR
[Forms]![YourFormName]![ComboBoxName] = "All Plant"


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
B

buscher75

Thank You, I appreciate your time.

I used:
Like IIF([Forms]![YourFormName]![ComboBoxName] <> "All Plant",
[Forms]![YourFormName]![ComboBoxName], "*")


John Spencer said:
Better would be (Then you don't get unexpected results if you have department
names like "Shoes" and "Shoes-Accessories".

Like IIF([Forms]![YourFormName]![ComboBoxName] <> "All Plant",
[Forms]![YourFormName]![ComboBoxName], "*")

Or if the Department could ever be null then the following entered into the
criteria "cell" would return all records whether or not Department was null.

=[Forms]![YourFormName]![ComboBoxName] OR
[Forms]![YourFormName]![ComboBoxName] = "All Plant"


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

KARL said:
Try this in criteria --
Like IIF([Forms]![YourFormName]![CpomboBox] <> "All Plant",
[Forms]![YourFormName]![CpomboBox], "") & "*"
 

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