Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Microsoft access, parameter query based on form requires all controls to be used? (https://www.askmehelpdesk.com/showthread.php?t=486991)

  • Jul 10, 2010, 07:06 AM
    chaserracer83
    Microsoft access, parameter query based on form requires all controls to be used?
    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
  • Jul 10, 2010, 09:29 AM
    Scleros
    Quote:

    Originally Posted by chaserracer83 View Post
    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?

    Quote:

    Originally Posted by chaserracer83 View Post
    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.
  • Jul 10, 2010, 09:47 AM
    chaserracer83
    Comment on Scleros's post
    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
  • Jul 10, 2010, 11:02 AM
    Scleros
    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.

  • All times are GMT -7. The time now is 07:57 PM.