Results 1 to 4 of 4
  1. #1
    ballaterach is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    9

    Simpler alternative to multiple criteria/multiple queries


    Our customers can opt out of receiving any 3 of 30 items with their weekly vegbox. I need a simple way to find where 'Yes' has been recorded against any of those 30 veg. Clearly there are not 30 lines in the query design to enter Yes into and the only alternative I have come up with (excuse my ignorance) is to have 4 seperate queries covering all 30 veg
    I'm guessing there must be a simpler way. Thanks in advance!!

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    because the answer is so straightforward for normalised data, from your description I suspect your data is not normalised - i.e. like a spreadsheet

    If it is normalised, then you tables would be something like

    tblOrders
    OrderPK autonumber
    CustomerFK long
    OrderDate Date

    tblOrdered
    OrderPK autonumber
    Item text (or perhaps a FK to another table to list your veg)
    Include yes/no

    and your query would be

    SELECT *
    FROM tblOrders INNER JOIN tblOrdered ON tblOrders.OrderPK=tblOrdered.OrderFK
    WHERE Include=yes

    But I suspect you have a table like this

    OrderPK autonumber
    CustomerFK long
    OrderDate Date
    Lettuce yes/no
    Tomatoes yes/no
    Potatoes yes/no
    etc

    If your table is as I suspect then as you say, you will need to have 30 OR's in your query. with regards
    Clearly there are not 30 lines in the query design to enter Yes
    in the query gui window, there aren't, but you can view the query in sql view and add as many OR's to the criteria as you like, there may be a limit but it is well over 30.

    The problem with your way is if you add or remove a veg, you need to modify the table and all queries, forms and reports. The normalised way - no change required.

  3. #3
    ballaterach is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    9
    Quote Originally Posted by Ajax View Post
    because the answer is so straightforward for normalised data, from your description I suspect your data is not normalised - i.e. like a spreadsheet

    If it is normalised, then you tables would be something like

    tblOrders
    OrderPK autonumber
    CustomerFK long
    OrderDate Date

    tblOrdered
    OrderPK autonumber
    Item text (or perhaps a FK to another table to list your veg)
    Include yes/no

    and your query would be

    SELECT *
    FROM tblOrders INNER JOIN tblOrdered ON tblOrders.OrderPK=tblOrdered.OrderFK
    WHERE Include=yes

    But I suspect you have a table like this

    OrderPK autonumber
    CustomerFK long
    OrderDate Date
    Lettuce yes/no
    Tomatoes yes/no
    Potatoes yes/no
    etc

    If your table is as I suspect then as you say, you will need to have 30 OR's in your query. with regards
    in the query gui window, there aren't, but you can view the query in sql view and add as many OR's to the criteria as you like, there may be a limit but it is well over 30.

    The problem with your way is if you add or remove a veg, you need to modify the table and all queries, forms and reports. The normalised way - no change required.

    You're correct Ajax it is NOT normalised; maybe I can redo the database but many thanks for your quick very helpful reply

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    you will soon see the benefits of normalisation

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

Similar Threads

  1. Replies: 6
    Last Post: 07-03-2015, 02:40 AM
  2. Replies: 3
    Last Post: 04-18-2015, 05:24 PM
  3. Replies: 1
    Last Post: 01-10-2012, 10:12 PM
  4. Replies: 1
    Last Post: 07-25-2011, 09:57 AM
  5. Replies: 1
    Last Post: 07-02-2010, 03:55 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