Results 1 to 4 of 4
  1. #1
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109

    Dlookup Issue. Finding Data Using Multiple Criteria and Updating Table

    I did some searches but can't find my exact problem. I will try to explain what I am doing so everyone can visualize it. I am trying to mass add some information from an import and to do so I need to do a lookup of one table to fill in the value on another. I listed the 2 tables below with their corresponding fields. I did an update query on ImportTest table with only Category_ID from the ImportTest table showing. I want to update it to the [Directory].[ID] value where the Department, Division, Function and Category are equal for both tables. There is only going to be one record that matches. I listed the expression I have been working on below in code tags.


    Directory (Table)
    ID <--Number I need
    Department (Text)
    Division (Text)


    Function (Text)
    Category (Text)

    ImportTest (Table)
    ID
    Category_ID (Number)<--need to fill in number here
    Department (Text)
    Division (Text)
    Function (Text)
    Category (Text)

    Code:
    =Dlookup ("ID","Directory","Department = [ImportTest].[Department] And 
    Division = [ImportTest].[Division] And 
    Function = [ImportTest].[Function] And 
    Category = [ImportTest].[Category]")

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What was the outcome of your test?

    Variable criteria need to be concatenated. References to the ImportTest fields are variables.

    Therefore, concatenate the fields (assume all fields are text type):

    =Dlookup("ID","Directory","Department='" & [ImportTest].[Department] & "' And Division='" & [ImportTest].[Division] & "' And
    Function='" & [ImportTest].[Function] & "' And Category='" & [ImportTest].[Category] & "'")
    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
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109
    Thank you for your replay. I was just going to post that I figured it out when I saw you answered. The solution I figured out is below. You have single quotes on the outside when I have them on the inside but I am guessing it doesn't matter if we're consistent with whatever method we use.

    DLookUp("[ID]","Directory","[Department]='" & [ImportTest].[Department] & "'And [Division]='" & [ImportTest].[Division] & "' And [Function] ='" & [ImportTest].[Function] & "' And [Category] ='" & [ImportTest].[Category] & "'")

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What you posted is the same as my suggestion, except for a missing space in front of the And before [Division].

    Order does matter. Single and double quotes must be in pairs and single quotes must be within double quotes.
    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: 11
    Last Post: 04-30-2012, 07:22 PM
  2. Populating a field from another table using DLookup
    By Jamescdawson in forum Access
    Replies: 22
    Last Post: 03-16-2012, 09:59 AM
  3. Replies: 1
    Last Post: 08-13-2011, 12:03 AM
  4. Multiple criteria in DLookup
    By crowegreg in forum Forms
    Replies: 7
    Last Post: 06-22-2011, 01:47 AM
  5. Replies: 18
    Last Post: 04-21-2011, 10:38 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