locked
Dsum returns null with date criteria RRS feed

  • Question

  • I'm using Dsum with a date criteria in a textbox in form1 where tdate in table [T] is before the text box [tar]

    =DSum("[T].[total]","[T]","[T].[tdate]="&<[forms]![form1]![tar])

    but it returns null in the textbox.. I tried to add "#" before and after tar .. and tried to put quotation before and after the criteria but nothing worked .. can I know whats wrong with it ?

    thank you 

    Monday, October 2, 2017 7:11 AM

Answers

  • What about

    =DSum("[T].[total]","[T]","[T].[tdate]<" & Forms![form1]![tar])

    Don't forget :

    • dates need to be surrounded by #
    • string need to be surrounded by '

    So, in fact, I'd probably be something more like

    =DSum("[T].[total]","[T]","[T].[tdate]<" & Format(Forms![form1]![tar], "\#mm\/dd\/yyyy\#"))


    Daniel Pineault, 2010-2017 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    • Marked as answer by moaaz-96 Tuesday, October 3, 2017 6:26 AM
    Monday, October 2, 2017 11:42 AM

All replies

  • What about

    =DSum("[T].[total]","[T]","[T].[tdate]<" & Forms![form1]![tar])

    Don't forget :

    • dates need to be surrounded by #
    • string need to be surrounded by '

    So, in fact, I'd probably be something more like

    =DSum("[T].[total]","[T]","[T].[tdate]<" & Format(Forms![form1]![tar], "\#mm\/dd\/yyyy\#"))


    Daniel Pineault, 2010-2017 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    • Marked as answer by moaaz-96 Tuesday, October 3, 2017 6:26 AM
    Monday, October 2, 2017 11:42 AM
  • thank you very much Daniel Pineault its working now :D
    Tuesday, October 3, 2017 6:26 AM