Results 1 to 4 of 4
  1. #1
    live2ride is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    70

    date function return value issue

    ok this is little bit frustrating. can someone please explain this issue



    Function fMod() As Date
    fMod= Nz(DLookup("DateModified", "tblUsers", "UserID = " & fUserID))
    End Function

    msgbox fMod (value = '12:00:00 AM') - wrong value
    msgbox Nz(DLookup("DateModified", "tblUsers", "UserID = " & fUserID)) (value = '10/24/2012 5:15:00 PM) - correct value

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I've seen something like that before. So I always define a variable first.
    what is the result if you try this?
    Code:
    Function fMod() As Date
      Dim tmp as Date
    
      tmp= Nz(DLookup("DateModified", "tblUsers", "UserID = " & fUserID))
      
      fMod= tmp
    End Function

  3. #3
    live2ride is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    70
    thats working fine, i always try to use the least amount of code as possible so thats why sometimes im trying to figure out these little issues which are irritating
    im constantly switching between access 2007 and 2010 and im having terrible time, while erything is working fine in one version other version fails all the time

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    You get 12:00:00 AM when you know DateModified field has 10/24/2012 5:15:00 PM or is the midnight time returned only for records where the DateModified field is Null?

    You use Nz function but don't specify a value to use if field is Null. I tested Nz in a query on various datatype fields and in VBA Immediate window. If no value specified, the result appears to be an empty string.

    The function is declared as Date but an empty string is not a date so maybe this is causing issue.
    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. Replace function adding in unwanted carriage return
    By timmygrover in forum Queries
    Replies: 10
    Last Post: 07-02-2012, 11:58 AM
  2. Replies: 3
    Last Post: 04-01-2012, 01:40 PM
  3. Function to return a set of records?
    By vicrauch in forum Access
    Replies: 2
    Last Post: 07-12-2011, 08:27 AM
  4. Replies: 1
    Last Post: 06-23-2010, 09:45 AM
  5. return last updated date for each product
    By jonnyuk3 in forum Queries
    Replies: 0
    Last Post: 06-17-2009, 04: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