Results 1 to 3 of 3
  1. #1
    shoelesscraig is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    53

    Query Question


    Hopefully this question makes sense. I have a table with 3 fields that are checkboxes (yes or no). We can call them C1, C2 and C3. Then I have a form from which I would like to run a query. On that form, there are 3 checkboxes, call them C1Test, C2Test, and C3Test. Basically, I'd like to check any combination of these 3 "test" checkboxes and then run the query and the query return me the records in the table where that combo exists.

    I can get close, but no cigar. If I only check C1Test, I want it to return records where C1 is Yes. (Same thing with C2 and C3). However, If I check C1Test AND C2Test, I'd like it to return records where C1 is Yes and records where C2 is Yes.....NOTE:: I don't want it to ONLY return records where BOTH are Yes....I literally want all records where EITHER C1 or C2 are Yes.

    Make any sense at all?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Did you try OR operator?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    John_G is offline VIP
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You can't simply test for equality (C1 = C1Test), because you will get records where both are False as well. You will need to use somthing like (C1Test And C1 = C1Test), and have one of those expressions for each checkbox, something like this:

    (C1Test And C1 = C1Test) OR (C2Test And C2 = C2Test) OR (C3Test And C3 = C3Test)

    Note the use of the parentheses!

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

Similar Threads

  1. Replies: 1
    Last Post: 05-17-2017, 01:21 AM
  2. Replies: 1
    Last Post: 03-05-2016, 05:22 AM
  3. Query question
    By jscriptor09 in forum Queries
    Replies: 1
    Last Post: 03-28-2014, 06:47 PM
  4. Query question
    By jerrypeco in forum Queries
    Replies: 20
    Last Post: 06-06-2013, 10:27 AM
  5. Query Question
    By gjennings1 in forum Access
    Replies: 5
    Last Post: 12-14-2011, 08:34 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