Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513

    dlookup() with date

    maybe there's a small nuance I'm missing when using DLookUp with a date as the criteria...
    my DMax returns correctly
    I do not get an error with my DLookup
    BUt the DlookUp retuns the wrong value...

    perplexed.. (but with thanks in advance for any assistance), mark


    vMaxDate = DMax("[Version_Date]", "tblVersionInfo")
    vlblVersion_Info = DLookup("[Version_ID]", "tblVersionInfo", "'[Version_date] = " & vMaxDate & "'")
    Me.lblVersion_Info.Caption = vlblVersion_Info

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If it is a true date, you need to surround it with pound signs (#6/25/2012#).
    See here: http://www.techonthenet.com/access/f...in/dlookup.php

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Dates and strings (text) need delimiters. Strings use single or double quotes, while Dates use the hash (#).

    Try
    Code:
    vlblVersion_Info = DLookup("[Version_ID]", "tblVersionInfo", "[Version_date] = #" & vMaxDate & "#")
    Expanded: " [Version_date] = # " & vMaxDate & " # ")

  4. #4
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513
    thnx !!

    mark

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

Similar Threads

  1. Replies: 15
    Last Post: 04-06-2012, 10:57 AM
  2. Use DLookup to Retrieve Field Value from a Date?
    By Heatshiver in forum Programming
    Replies: 8
    Last Post: 04-06-2012, 10:09 AM
  3. displaying a date using DLookup
    By crowegreg in forum Forms
    Replies: 2
    Last Post: 08-25-2011, 05:24 PM
  4. Replies: 1
    Last Post: 06-17-2011, 12:59 AM
  5. Return DLookup result as date?
    By kman42 in forum Access
    Replies: 8
    Last Post: 04-22-2011, 11:35 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