Results 1 to 7 of 7
  1. #1
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48

    Dlookup

    Hi,



    Got one Dlookup function to work but not this one in my qryDepartment.

    Need some help, please view uploaded file.

    Br Bertrand
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Why DLookup - the data is already there, just include DpartmentEquals field in the query.


    Department is a text datatype field. Need apostrophe delimiters:

    Dlookup: DLookUp("[DepartmentEquals]","[DepartmentInformation]","[Department]='" & [Department] & "'")

    A date/time field would use # character.

    Better would be to join the tables in query. Domain aggregate functions can slow down queries.
    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
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48
    Thank you, it worked.

    And if the value is not found I want the Dlookup value to return "Unknown"

    What will the function be?

    Thanks in advance

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Nz(DLookUp("[DepartmentEquals]","[DepartmentInformation]","[Department]='" & [Department] & "'"), "Unknown")
    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.

  5. #5
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48
    HI June, Thank you.

    Though I have noticed that, as you said, the dlookup has slowed down my query.

    Do I join the tables by relationsships and get the same results as with the dlookup?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    I should have noted before that with a DLookup, you had the wrong table in the query - your query should have been:
    SELECT Department, DLookUp("[DepartmentEquals]","[DepartmentInformation]","[Department]='" & [Department] & "'") AS Dlookup FROM Data;

    A query joining tables would be:
    SELECT Data.Department, DepartmentEquals FROM Data LEFT JOIN DepartmentInformation ON Data.Department = DepartmentInformation.Department;
    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
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48
    Thank you June, Worked perfectly!

    Have a nice day.

    br Bertrand

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

Similar Threads

  1. Dlookup, please help
    By Anthony88 in forum Access
    Replies: 9
    Last Post: 04-17-2012, 11:33 AM
  2. Dlookup
    By cbrsix in forum Forms
    Replies: 2
    Last Post: 11-01-2011, 02:59 PM
  3. Help with DLookUp
    By focosi in forum Forms
    Replies: 10
    Last Post: 08-08-2011, 07:53 AM
  4. DLookup help
    By denners05 in forum Access
    Replies: 1
    Last Post: 06-11-2011, 12:55 PM
  5. May it is Dlookup
    By cap.zadi in forum Programming
    Replies: 3
    Last Post: 05-09-2011, 05:58 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