Results 1 to 4 of 4
  1. #1
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150

    DSUM Syntax with dates

    Hi,

    I'm having trouble getting the syntax right on below Dsum function, where I'm trying to sum the [Total Qty] if the [DateCompleted] is between two dates that I stored in a couple of TempVar variable. This is what I have so far. I have verified my TempVar variable result.


    Code:
    intTotalAdded = DSum("[Total Qty]", "MyTable", "[DateCompleted] between #" & [TempVars]![TempBeginDate] & "# and [DateCompleted] #" & [TempVars]![TempEndDate] & "#")

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Don't repeat the field name with Between.

    "[DateCompleted] between #" & [TempVars]![TempBeginDate] & "# and #" & [TempVars]![TempEndDate] & "#"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Works great. Thanks.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Help me with Dsum syntax for grouped running totals please
    By tbjmobile@gmail.com in forum Access
    Replies: 8
    Last Post: 06-18-2018, 06:30 AM
  2. dsum between dates
    By sdel_nevo in forum Programming
    Replies: 3
    Last Post: 02-09-2017, 10:53 AM
  3. Dsum, Syntax error
    By mike02 in forum Queries
    Replies: 5
    Last Post: 05-24-2013, 09:52 AM
  4. DSum syntax for report
    By dwilson in forum Access
    Replies: 2
    Last Post: 09-08-2011, 07:31 PM
  5. DSum Syntax Help
    By desk4tbc in forum Programming
    Replies: 2
    Last Post: 07-01-2011, 02:31 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