Results 1 to 10 of 10
  1. #1
    derek7467 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    46

    Using a DLOOKUP

    Afternoon!
    I need to use a dlookup on a report to look up fields on another query, other than what the report uses.

    How do i use the dlookup syntax?



    I have a field on another query called "Average" and the query name is AverageResults. The report is called Totals.

  2. #2
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    DLookup("<FieldName1>", "<QueryName>", "<FieldName2>=<Criteria>")

    FieldName1 will be the field you want to return a result from. Queryname is the name of the query you want to pull data from. FieldName2 can be any field in the query that you want to use to filter down to a specific row in your data. The criteria is whatever value you want to find out of FieldName2.

    In the third parameteter, you can use AND and OR's to evaluate other criteria as well. It is essentially the "WHERE" clause of a query without the actual WHERE keyword.

    DLookup("Average", "AverageResults", "ID=2 AND TimeStamp < #1/14/2014#") for example.

  3. #3
    derek7467 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    46
    What if i just wanted to display one field from another query, would this work?:

    =DLookUp("Avg ACD Calls","SupervisorDailyHuddle - Averages")

    Where Avg ACD Calls is the field from the query SupervisorDaily Huddle - Averages; do i have to put a Criteria clause in there?

  4. #4
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Quote Originally Posted by derek7467 View Post
    What if i just wanted to display one field from another query, would this work?:

    =DLookUp("Avg ACD Calls","SupervisorDailyHuddle - Averages")

    Where Avg ACD Calls is the field from the query SupervisorDaily Huddle - Averages; do i have to put a Criteria clause in there?
    It seems either I didn't explain it well enough or you made the same mistake I occasionally do and didn't read the whole post.

    The first field IS THE FIELD OF DATA TO DISPLAY. You will get only ONE single result back.

    The DLookup function takes three string arguments. The first argument is the FIELD of the query or table you want to return. The second argument is the name of the table or query you want to get the data from. The third argument is a criteria of how to narrow down which ROW of data the information is in, and it will return the first value that matches your criteria.

  5. #5
    derek7467 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    46
    I read the whole post; just didnt understand the third argument:
    The third argument is a criteria of how to narrow down which ROW of data the information is in, and it will return the first value that matches your criteria.

    Since its only one row in the data, since its an average:
    Click image for larger version. 

Name:	Capture.JPG 
Views:	10 
Size:	19.7 KB 
ID:	15496

    I want to return the Avg ACD Calls which is column 2 row 1.

    =DLookUp("Avg ACD Calls","SupervisorDailyHuddle - Averages", "Avg ACD Calls=1")???

    Lastly, im then placing a text box on my report on the footer, and using the Control Source to input my dlookup?

    Sorry for all the ?'s I appreciate the help.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    The WHERE CONDITION argument could be like:

    =DLookup("Avg ACD Calls", "SupervisorDailyHuddle", "LoginDate=#2/2/2014#")

    Is SupervisorDailyHuddle a query? Does it aggregate the calls by date?
    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.

  7. #7
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Quote Originally Posted by june7 View Post
    the where condition argument could be like:

    =dlookup("avg acd calls", "supervisordailyhuddle", "logindate=#2/2/2014#")

    is supervisordailyhuddle a query? Does it aggregate the calls by date?
    this ----^

  8. #8
    derek7467 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    46
    Thanks guys. testing it now. June, yes its an aggregate function, and avgs the columns by a certain date.

  9. #9
    derek7467 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    46
    When i use =dlookup("avg acd calls", "supervisordailyhuddle", "logindate=#2/2/2014#")

    I get an #Error:

    Here is how i am placing it on my Report
    Click image for larger version. 

Name:	Capture1.JPG 
Views:	9 
Size:	133.8 KB 
ID:	15502

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Field names have spaces, try enclosing in [].

    Advise avoid spaces and special characters/punctuation (underscore is exception) in naming convention.

    If you want the date criteria to be dynamic and reference the LoginDate from the footer:

    =DLookup("[Avg ACD Calls]", "SupervisorDailyHuddle", "LoginDate=#" & [LoginDate] & "#")
    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. DLOOKUP Help
    By UTLee in forum Access
    Replies: 8
    Last Post: 08-29-2013, 09:48 AM
  2. VBA dlookup but with where
    By Ruegen in forum Forms
    Replies: 7
    Last Post: 08-20-2013, 12:23 AM
  3. Like in Dlookup
    By msp4422 in forum Programming
    Replies: 3
    Last Post: 02-19-2013, 04:02 PM
  4. Help with a Dlookup
    By funkygoorilla in forum Programming
    Replies: 1
    Last Post: 01-21-2012, 10:04 AM
  5. dlookup
    By ali zaib in forum Access
    Replies: 3
    Last Post: 01-13-2012, 11:57 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