Log in

View Full Version : Microsoft access, parameter query based on form requires all controls to be used?


chaserracer83
Jul 10, 2010, 07:06 AM
Hi,

I am trying to run a parameter query from a form in Microsoft access 2010. I am using 7 different combo boxes. The combo box lists are populated from different queries. I was wanting to have the query take the values from the combo box only if the user selected a value form the box. I have the query set up from each combo box from the form (example [Forms]![frmProductSearch]![ProductCategoryCombo]). The query works if all the combo boxes are used and there happens to be a record with those variables but if a combo box is not used it doesn't return anything. I have tried everything I can think of to get this to work but can't. My default value in the combo box is blank. Any suggestions?

Thank you for your time,
Chase

Scleros
Jul 10, 2010, 09:29 AM
The query works if all the combo boxes are used and there happens to be a record with those variables but if a combo box is not used it doesn't return anything.

Well, yeah. Something has to be queried for, otherwise what's the point of running the query? What do you expect to be returned when querying for nothing?


My default value in the combo box is blank. Any suggestions?

Set default values for all the combo boxes or else pop up a message box stating the minimum number of combo boxes that have to be populated in order to run the query.

chaserracer83
Jul 10, 2010, 09:47 AM
Yes... I understand how a query works. What I am saying is that of the 7 combo boxes I would like for the user to be allowed to use as few as one or as many as 7. I would like for the query to ignore a combo box that has not been selected. If the def

Scleros
Jul 10, 2010, 11:02 AM
Create a post with your additional information instead of attempting to put it all in an agree/disagree.

If one or all of the comboboxes can be used, you can:
A. Parse the input from the comboboxes with some custom code and then query using only the provided parameters.
B. Check the comboboxes for input with code and if they haven't changed pass a predetermined set of parameters to the query so that it returns a result or else pops up a message that one or more inputs are required.
C. Set appropriate defaults in the comboboxes so that the query returns a result if the user doesn't provide input.

A blank does not equate to "don't care"; it equates to an empty string, which means that field must be empty for the record to be returned. If you truly don't care, that parameter can be passed to the query as a wildcard (*) which could also be set as the default so that all records are returned if the user doesn't enter any input.