Results 1 to 4 of 4
  1. #1
    misahil is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    2

    How to Format Date parameter in Dsum

    I m using Access 2010. I m Facing a problem in the undermentioned query



    OPB: 1*Nz(DSum("[Trans]","LogDetail","[LocationID]='" & [LocationID] & "' AND [ProductID]='" & [ProductID] & "' AND [LogDate]<#" & Format([FromDt],"dd-mm-yy") & "#"),0)

    when i run the query it gives "Undefined Function 'Format' in Expression"

    I will be very thankful if someone let me know where is the mistake and what is the correct express.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Are LocationID and ProductID number data type? If yes, remove the apostrophes.

    Why do you need to format the date parameter? Is LogDate a date type field? Access expects dates to be mm/dd/yyyy.
    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
    misahil is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    2
    Thanks for your reply.

    1. Are LocationID and ProductID number data type? No, These field are Text data type.
    2. Yes LogDate is Date type field.
    3. In our region the date format is dd/mm/yy that's why i need to change the format.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Regardless of regional date display settings, Access still stores the date value as a number.

    Have you reviewed http://allenbrowne.com/ser-36.html

    The Format() function should work in a query. Format() results in a string, however, enclosing with # delimiters attempts to treat the string as a date value.

    Since I use Access/US dates, never been an issue for me and I am not sure how to resolve. If you want to allow users to input parameters as dd-mm-yyyy, have to make sure Access doesn't misinterpret. A comparison of stored date (mm/dd/yyyy - 5/4/2014) will not match to input string value of dd-mm-yyyy - 4/5/2014). Don't set input boxes Format property as a date. Use InputMask to control user input. Then manipulate the string input to convert to date for saving to table or in filter criteria.

    Try:

    CDate(Format([FromDt],"dd-mm-yy"))

    or

    DateValue(Format([FromDt],"dd-mm-yy"))
    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. Replies: 4
    Last Post: 03-12-2013, 06:49 PM
  2. Replies: 6
    Last Post: 02-28-2013, 05:38 PM
  3. Query parameter prompt - Format message
    By daved292 in forum Queries
    Replies: 2
    Last Post: 06-08-2012, 11:09 AM
  4. how to format the dsum value?
    By polis in forum Queries
    Replies: 7
    Last Post: 09-06-2011, 04:52 PM
  5. DSUM with date criteria from form
    By krutoigoga in forum Reports
    Replies: 4
    Last Post: 07-28-2010, 01:32 PM

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