Results 1 to 3 of 3
  1. #1
    amai is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    12

    DLookup with multiple criteria

    I am trying to have a DLookup with two criteria. I am able to make it work when I try only one criteria at a time.

    First Criteria (works well)
    =DLookUp("[InvoicesQry]![Qty]","[InvoicesQry]"," [InvoicesQry]![ContractNumber] ='" & [Forms]![OrderForm]![ContractNumber] & "'")

    Second Criteria (works well)
    =DLookUp("[InvoicesQry]![Qty]","[InvoicesQry]"," [InvoicesQry]![ItemNumber] = '" & [Forms]![OrderForm]![ItemNumber] & "'")

    I have tried several ways to put them together with no success. Below is the closest I have got in my trials. I do not get any errors but it does not retrieve any values and, when I add NZ with 0 value, it gives me 0.

    =DLookUp("[InvoicesQry]![Qty]","[InvoicesQry]"," [InvoicesQry]![ContractNumber] ='" & [Forms]![OrderForm]![ContractNumber] & " And [InvoicesQry]![ItemNumber]) =" & [Forms]![OrderForm]![ItemNumber] & "'")

    Any help will be appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,891
    Are ContractNumber and ItemNumber both text type fields? Missing apostrophe delimiters - need 2 pairs.

    =DLookUp("[InvoicesQry]![Qty]","[InvoicesQry]"," [InvoicesQry]![ContractNumber] ='" & [Forms]![OrderForm]![ContractNumber] & "' And [InvoicesQry]![ItemNumber]) ='" & [Forms]![OrderForm]![ItemNumber] & "'")
    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
    amai is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    12
    Perfect!!!! Thank you.

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

Similar Threads

  1. Help with multiple criteria DLookup
    By jtm013 in forum Programming
    Replies: 7
    Last Post: 04-23-2015, 03:16 PM
  2. DLookup with multiple criteria
    By RunTime91 in forum Access
    Replies: 4
    Last Post: 02-08-2015, 08:28 PM
  3. Dlookup multiple text criteria from vba variables
    By trevor40 in forum Programming
    Replies: 4
    Last Post: 02-03-2015, 04:20 PM
  4. Using DLookup with multiple criteria
    By halt4814 in forum Access
    Replies: 2
    Last Post: 04-08-2013, 12:26 PM
  5. Multiple criteria in DLookup
    By crowegreg in forum Forms
    Replies: 7
    Last Post: 06-22-2011, 01:47 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