Results 1 to 5 of 5
  1. #1
    hksahoo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2013
    Posts
    12

    Syntax Error Dsum Function with date range

    I am getting synatx error in the following expression:



    Dsum(“[Dep]”,”[InterestTable]”,”[Tdate]>=#01/04/2021# and <=#31/03/2022#”)

    Please Help

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,131
    You have to repeat the field name:

    Dsum(“[Dep]”,”[InterestTable]”,”[Tdate]>=#01/04/2021# and [Tdate] <=#31/03/2022#”)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    2,774
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    hksahoo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2013
    Posts
    12
    Tried Dsum(“[Dep]”,”[InterestTable]”,”[Tdate]>=#01/04/2021# and [Tdate] <=#31/03/2022#”) but getting syntax error.
    Date format in the table is dd/mm/yyyy

  5. #5
    Eugene-LS's Avatar
    Eugene-LS is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2018
    Location
    Murmansk
    Posts
    17
    Quote Originally Posted by hksahoo View Post
    Tried Dsum(“[Dep]”,”[InterestTable]”,”[Tdate]>=#01/04/2021# and [Tdate] <=#31/03/2022#”) but getting syntax error.
    Works:
    Code:
    Dim vVal
        vVal = DSum("Dep", "InterestTable", "[Tdate] Between #01/04/2021# and #31/03/2022#")
    BTW:
    "[Tdate]>=#01/04/2021# and [Tdate] <=#31/03/2022#" = "[Tdate] Between #01/04/2021# and #31/03/2022#"

    Click image for larger version. 

Name:	Снимок.PNG 
Views:	11 
Size:	12.8 KB 
ID:	46404

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

Similar Threads

  1. Replies: 4
    Last Post: 04-21-2015, 07:12 PM
  2. Use the Date as a criteria in Dsum function
    By Ank_db in forum Queries
    Replies: 1
    Last Post: 01-18-2015, 12:08 PM
  3. Replies: 43
    Last Post: 08-06-2014, 08:21 PM
  4. Dsum, Syntax error
    By mike02 in forum Queries
    Replies: 5
    Last Post: 05-24-2013, 09:52 AM
  5. Using a date range with Dcount function
    By mleberso in forum Reports
    Replies: 4
    Last Post: 06-17-2011, 08:56 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