Results 1 to 4 of 4
  1. #1
    Mikey1987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Posts
    19

    select query find category of value where value is between two other values

    Hello,

    I feel silly for asking such an easy question, but I can't figure out how to do this in access query design view.

    I have two tables:
    First table has 1 column "Score"
    My second table has 3 columns: "Lower", "Upper" and "Type"

    What I want, is to match the type with the score, where score is >= Lower and <= Upper

    Let's say my second table is like this:
    Lower / Upper / Type
    0 / 4 / Bad
    5 / 8 / Good
    9 / 10 / Very good

    and my other table contains these scores
    3
    6
    8
    9




    then I want a query that says
    3 Bad
    6 Good
    8 Good
    9 Very good

    Can you please tell me how I can do this in design view, and not in SQL?

    Thanks very much

    Mikey

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Well, the most efficient method is probably a non-equi join, but that can't be done in design view. To avoid SQL view you're looking at either a subquery or a DLookup(), either with a criteria that in essence says "Score Between Lower And Upper".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Mikey1987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Posts
    19
    Hm, dlookup might be a good tip

    However, I can't get it to work. My dlookup results in all blanks

    This is the formula I'm using
    MyAttempt: DLookUp("[Type]","Limits","[Bottom]>=" & [Number] & "AND[Top]<=" & [Number])

    the field's name is "Type", the table name is "Limits" and I want the type where the "Number" is between Bottom and Top.
    Do you see the mistake?

    Cheers,
    Mikey

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Your logic is reversed (<>).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Query to find Values that do NOT exist
    By SoonerLater in forum Queries
    Replies: 4
    Last Post: 09-19-2015, 06:29 PM
  2. Replies: 5
    Last Post: 05-10-2014, 09:24 AM
  3. Query: select latest date within given category
    By martinhough in forum Queries
    Replies: 4
    Last Post: 10-22-2013, 12:34 PM
  4. Count Unique Values in a Category
    By fionny in forum Queries
    Replies: 2
    Last Post: 06-28-2013, 02:28 AM
  5. Replies: 1
    Last Post: 10-06-2009, 02:00 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