Results 1 to 4 of 4
  1. #1
    emanual4real is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    6

    Dlookup

    I'm having trouble getting DLookup to work for me.
    Here's what I've got: [Action Details] Table. [Action Query] query. [Action Form] form.

    Query
    SELECT [Action Details].employee, [Action Details].[Action Date], [Action Details].[Action Taken]
    FROM [Action Details]
    WHERE ((([Action Details].Employee)="username") And (([Action Details].[Action Date])>(DateAdd("d",-90,Date()))));



    When the form opens, the query is updated based on the username to show all actions within 90 days for that user.
    On the form, I have a textbox =Max([Action Date]) which shows me the latest date of the action taken.
    The problem is another textbox, I want it to show the latest action taken.

    I've been told I need to use Dlookup, but it is not working for me.
    =DLookUp("[Action Taken]","[Action Details]","Max([Action Details]![Action Date])")

    Any help would be appreciated.
    TY

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Try:

    =DLookup("[Action Taken]", "[Action Details]", "Employee='" & [Employee] & "' AND [Action Date]=#" & DMax("[Action Date]", "[Action Details]", "Employee='" & [Employee] & "'") & "#")
    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
    emanual4real is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    6
    Ok, wow, that worked first try! Since I wasn't including the [Employee], was it trying to pull more than one record and can't display more than 1 in a textbox?

    Thanks again!!!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Domain aggregate functions return a single value, not records.

    The DLookup returns value from first record it hits that meets criteria.

    The criteria was bad syntax.
    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
    By cap.zadi in forum Forms
    Replies: 5
    Last Post: 09-21-2011, 07:16 PM
  2. Help with DLookUp
    By focosi in forum Forms
    Replies: 10
    Last Post: 08-08-2011, 07:53 AM
  3. May it is Dlookup
    By cap.zadi in forum Programming
    Replies: 3
    Last Post: 05-09-2011, 05:58 AM
  4. dlookup help
    By gsantacruz in forum Programming
    Replies: 9
    Last Post: 10-11-2010, 11:46 AM
  5. DLookup()
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 09-15-2010, 07:20 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