Results 1 to 5 of 5
  1. #1
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86

    Select Query on Criteria or Blank?

    Hi Everyone,



    I am trying to build a select query that looks up records in Table A. I am trying to allow the end users of the database to select the criteria for this query by filling in data into Table B and having Table A & B related. So far, this is working fine by telling my query to return values in Field 1 from Table A that match the values in Field 1 of Table B.

    However, I want to give the end users the option of leaving a data field in Table B blank, thereby not specifying any criteria and returning all values in Table A. That is where I am running into a problem. Any suggestions?

  2. #2
    Rhino373 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    65
    I'd measure the recordcount of table B and if it is zero, I'd run a different SELECT query that returns all of table A.

  3. #3
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86
    Isn't there some way of structuring the one query so that it returns either records in Table A that match the criteria set up by Table B OR returns all of Table A when Table B IS Null?

  4. #4
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86
    Ok, I think I am getting close here. In the query criteria I have the following expression:

    IIf(IsNull([Date Query].[Exposure Setting])," ",[Date Query].[Exposure Setting])

    Right now this should be saying: if the exposure setting field in the Date Query Table is blank, then return a blank space, if it is not null, return the value in the exposure setting field of the Date Query table.

    Is there a way to fill in that " " so that if this field is null, it returns everything in this field? Something along the lines of using "Like" or an *... I cannot figure out exactly how to tell it to return everything...

  5. #5
    batowl is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    86
    Ok, solved, temporarily at least. The solution is:
    [type prompt here] Or Like [repeat prompt here] Is Null

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multi-Select List Box as Criteria in Query
    By broadwat in forum Queries
    Replies: 6
    Last Post: 09-19-2011, 07:47 AM
  2. Replies: 1
    Last Post: 07-13-2011, 11:00 AM
  3. Passing Multi Select string to Query criteria
    By oleBucky in forum Queries
    Replies: 4
    Last Post: 05-15-2011, 02:11 PM
  4. Replies: 2
    Last Post: 03-31-2009, 11:15 AM
  5. Select query with two criteria
    By corni in forum Queries
    Replies: 1
    Last Post: 01-22-2009, 05:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums