Results 1 to 8 of 8
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    Multiple criteria in DLookup


    Are you able to have 2 criterias in a DLookup statement? Here's the vital info:
    Expr: OnHandQty
    table name: ICPartWarehouse
    criteria: FKICPart = me.FKICPart and WarehouseNumber = 3
    both FKICPart & WarehouseNumber are fields within the table

    Here's what I have so far:
    =DLookUp("OnHandQty","ICPartWarehouse",????)

    Thanks for your assistance!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You can have has many criteria as you want, as far as the ControlSource string length limit will allow. If FKICPart is a number datatype, remove the apostrophe delimiters. The Me qualifier is VBA, can't use in Access.
    =DLookUp("OnHandQty","ICPartWarehouse", "FKICPart ='" & [FKICPart] & "' And WarehouseNumber = 3")
    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
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I receive an error. Both FKICPart and WarehouseNumber are fields within the table, and both are numeric. In the search criteria I need FKICPart = text190 and WarehouseNumber = 3.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    =DLookUp("OnHandQty","ICPartWarehouse", "FKICPart = '" & Me.text190 & "' And WarehouseNumber = 3")

  5. #5
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thanks for the assistance. I've been testing different things, and nothing has worked yet. I pasted your suggestion, and I had to change WarehouseNumber to WarehouseNo. Within the field I'm receiving #Name? If I trouble shoot with only using 1 criteria, it works properly. When I add the second criteria, I receive the error message. When I only use 1 criteria, I'm manipulating the data so I only have 1 match.

  6. #6
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I should also write that text190 is a Dlookup. Here's what is in text190, =DLookUp("SKICPart","ICPart","ID ='" & [ISBNBW] & "'"). Within the dlookup that I'm having the problem, all fields are numeric. In the Dlookup that is in text190, SKICPart is numeric, and ID & ISBNBW are text.

  7. #7
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    After spending many hours on this with no solution, I decided to write VBA behind the form. It works great. Maybe there is a problem within Access 2010 an multiple criteria in a DLookup.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    No, multiple criteria works fine. However, my DLookup used a field in the form's recordset as criteria. Never tried a DLookup that used the results of another DLookup. Did not test but problem must be with that.
    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. Replies: 1
    Last Post: 06-17-2011, 12:59 AM
  2. Search with multiple criteria
    By injanib in forum Forms
    Replies: 1
    Last Post: 01-16-2011, 11:51 PM
  3. Multiple Criteria in a string
    By cksm4 in forum Programming
    Replies: 3
    Last Post: 08-04-2010, 11:54 AM
  4. Dlookup to match two criteria and return value
    By randolphoralph in forum Programming
    Replies: 20
    Last Post: 05-20-2010, 12:27 PM
  5. Multiple criteria query
    By DJ-Specter in forum Queries
    Replies: 1
    Last Post: 09-23-2009, 04: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