Results 1 to 5 of 5
  1. #1
    mindea is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    11

    How to show who DIDN'T buy a particular item.

    Seems like this simple scenario would have been covered a zillion times (and probably has) but my searches have not come up with an answer. (Maybe I need help doing web searches!)

    Here's my [grossly simplified] issue. I have a table that stores purchase history -- that is, who bought what color balloons.

    Jack - red
    Jack - blue
    Jack - yellow
    Lane - blue
    Lane - yellow
    Lane - green
    Fred - red
    Fred - blue


    Fred - yellow

    The boss wants to know who didn't buy any red balloons. He'd also like to know who didn't buy any green balloons.

    Can someone point out how I would go about this?
    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    SELECT * FROM people WHERE peopleID NOT IN (SELECT peopleID FROM purchases WHERE color = 'red");

    Do the same for green.
    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
    mindea is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    11
    Thank you for that June7. I've been away from Access for a bit and completely forgot about the NOT IN statement.

    I've tried your suggestion on my actual tables and it seems to be taking forever to run.
    The NOT IN select statement (which I had to make SELECT DISTINCT to get unique peopleIDs) returns 14 records.
    My actual Purchases table contains 130,000 records.
    Like I say, it just runs without ever showing a result.
    I quickly created a table (tbl_NotRed_peopleID) with those 14 peopleIDs and then made the NOT IN statement: NOT IN (SELECT peopleID FROM tbl_NotRed_peopleID); and that works fine.
    Could it be the SELECT DISTINCT in the NOT IN statement is causing the problem?

  4. #4
    mindea is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    11
    Gak! Got it working now. I unintentionally had the outer SELECT section with SELECT DISTINCT. Now it's working. Many thanks again for your help.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Don't really need DISTINCT.
    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.

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

Similar Threads

  1. show combobox item instead value
    By Milad Roohi in forum Access
    Replies: 1
    Last Post: 05-26-2016, 03:10 PM
  2. Show Checkbox when listbox item is selected
    By gammaman in forum Modules
    Replies: 5
    Last Post: 06-04-2015, 09:46 AM
  3. Show Related Item on Form
    By crawfish124 in forum Forms
    Replies: 1
    Last Post: 05-14-2014, 03:33 PM
  4. Show how many times an item is sold?
    By xtrareal22 in forum Forms
    Replies: 4
    Last Post: 11-29-2013, 08:33 AM
  5. Replies: 9
    Last Post: 04-02-2013, 07:22 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