Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010

    Unanswered: WHERE Clause Wildcard

    Hi guys,

    I have a form that allows my users to generate custom reports.

    I build out the report's SQL code dynamically using VBA.
    The WHERE clauses all look something like this...

    "WHERE tblManufacturer.ID = " & Me.cboManufacturer 'result of user selected combo box
    Me.cboManufacturer is a combo box on the user form. The only problem is that I'd like the user to select an "ALL" option that would display a report with data from all manufacturers rather than limiting the result set to just one.

    It doesn't look like SQL allows a * wildcard to be used... for example..
     WHERE x = *
    throws and error.

    Is there any wildcard I can use for this case? Or do I have to rework a bunch of my code to allow for that case?

  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    Since you're building the SQL in code, simply leave off the WHERE clause if the user doesn't fill out that combo, or selects "ALL".

  3. #3
    Join Date
    Sep 2012
    I perfectly agree with "pbaldy"
    I have similar functionality in my database. What I do is to check if the filter fields are filled up then continue building the WHERE clause if there is any.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts