Full Version: Query Parameter from Combo Box
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
luvfuzz
Using report, based on Query, which derives a certain parameter from a combo box control on a form. When I press a button on the form, it launches the report. The control's source is a table

I am trying to figure out a way to allow the control to have an ALL function.

My only idea has been to simply add a record to the appropriate table that just says ALL, then, in the query criteria I used an IIF statement to say that if the control value was anything other than the ALL entry, use the control value, otherwise, do not include the criteria.

CODE
IIf([Forms]![frm_reportParameters].[cbo_facility].[value]<5,[Forms]![frm_reportParameters].[cbo_facility].[value],<=5)


(there are only four records in tbl_facility, the fifth is the ALL entry). When I select any facility, it works as expected, but when I select ALL, the query returns no entries.

Any ideas?
dashiellx2000
You may just want to use "" instead of the <=5. Also, you may want to use a dynamic query. Check here for more info.

HTH.
ScottGem
See here
fkegley
I have prepared a demo showing how I would do it. See CategoriesCriteriaForm in the attached example.
luvfuzz
AHHA!!!! I thought you had lost me...but I got it. The example was extremely helpful. It took some thinking to realize that you were just choosing from one of the two queries. I thought you were using one query no matter what.

Thanks for the help.
fkegley
You're welcome. That seemed like the KISS way to me. I always pick the KISS way.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.