Results 1 to 5 of 5
  1. #1
    EffBee is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Posts
    3

    Help with a basic IIF query please

    Hello,
    I have fruit table, personToFruit junction table and a Person table.
    Fruits are Apples, bananas and pears.



    In my query I would like to identify who has more than one fruit (each person should only have 1 if any).

    I have created a new field in the query asking if Person has apple&bqnanas Or apple&pears Or Etc, then "Flag" otherwise "". But doesn't work.

    Any help is appreciated.

    Thanks
    Last edited by EffBee; 03-08-2019 at 04:47 AM. Reason: Title

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This is your real database? fruits and persons? How would multiple fruit be entered? Separate records?
    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
    EffBee is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Posts
    3
    Yes, in the junction table.
    Person1, Apple
    Person1, Pear
    Person2, pear
    Person3, Apple
    Person3, Banana

  4. #4
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    A simple count of persons would give you what you need. Air SQL untested


    Code:
    SELECT Count(PersonID) as FruitQty, PersonID FROM tblPersonFruit GROUP BY PersonID Having Count(PersonID) >1
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If persons can have only 1 fruit associated there would be no need for a junction table. Don't understand issue.
    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. Help with Basic SQL Code for a Query!
    By Antonio in forum Queries
    Replies: 18
    Last Post: 04-30-2018, 01:52 PM
  2. Help with basic query
    By UTLee in forum Queries
    Replies: 2
    Last Post: 11-25-2015, 10:27 AM
  3. Basic Query Help
    By UTLee in forum Queries
    Replies: 3
    Last Post: 09-29-2015, 09:51 AM
  4. Query Help VERY BASIC
    By nparrillo in forum Queries
    Replies: 5
    Last Post: 04-06-2011, 11:15 AM
  5. basic query codes
    By joms222 in forum Queries
    Replies: 1
    Last Post: 03-20-2009, 11:31 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