Results 1 to 2 of 2
  1. #1
    jobrien4 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    20

    Dlookup to find value in a range

    I am trying to use the Dlookup function but am running into some issues when I try to use multiple criteria.



    I have a table that has the a price for a given range of thicknesses. I want the Dlookup to pull the price from the correct range. The ranges are defined by two fields, LowThickness and HighThickness.

    For example, let's say I have a different price if the thickness is 0 to 1, 1 - 2, and anything over 2. I want the user to be able to input a number, say 1.556, and have it lookup the correct cost from the 1-2 range.

    Here is what I have:

    MaterialCost = DLookup ( "[Cost]","[tbl_MaterialCost", "[LowThickness]< " & Thickness And "[HighThickness] >= " & Thickness & "")

    What am I doing wrong?

    Edit: If there is a better or simpler way to accomplish this, including redesiging the tables involved, I'm all ears.

  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,521
    You've got the And outside the quotes, and didn't include the &. This has a multi-criteria example:

    DLookup Usage Samples

    Another option would be a non-equi join.
    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. Date range Q
    By markjet in forum Queries
    Replies: 13
    Last Post: 07-18-2011, 01:00 PM
  2. Subscript out of range (9)
    By msche398 in forum Programming
    Replies: 1
    Last Post: 07-08-2011, 12:52 PM
  3. Replies: 1
    Last Post: 06-17-2011, 12:59 AM
  4. Replies: 2
    Last Post: 11-25-2010, 11:01 AM
  5. age range summary
    By maintt in forum Reports
    Replies: 10
    Last Post: 07-19-2010, 02:24 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