Results 1 to 11 of 11
  1. #1
    KRS@WAC is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    3

    DSUM expression on longer working


    I'm a newb, studying Access and trying to get a reporting database going again after sitting dormant for some time. I've solved several issues, but this one is stumping me. Any help appreciated, thanks!

    This used to work, I've see old reports where it did. Now it returns #ERROR

    =DSum("[Total]","Total Loans","Date Between #" & [Start Date] & "# And #" & [End Date] & "#")

    Total is the column, Total Loans is the query, the expression works if I take out the date criteria, but I need the sum between a data range. This appears in the footer section of a report, but this table is NOT part of the query the report is built on.

    Screen Cap of the query "Total Loans" is attached.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    So what has changed since it last worked?

    Next time, Instead of link to image, try embedding in the post - make it easier for readers to help you.

    Date is a reserved word and really should not use reserved words as names for anything.

    Try enclosing Date in [], like: [Date] Between

    If still need help, post the query SQL statement or provide the db. Follow instructions at bottom of my post.
    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
    KRS@WAC is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    3

    Thanks

    Quote Originally Posted by June7 View Post
    So what has changed since it last worked?

    Next time, Instead of link to image, try embedding in the post - make it easier for readers to help you.

    Date is a reserved word and really should not use reserved words as names for anything.

    Try enclosing Date in [], like: [Date] Between

    If still need help, post the query SQL statement or provide the db. Follow instructions at bottom of my post.

    IDK what could have changed, I just took over this thing. Here is the SQL

    =DSum("[Total]","Total Loans","Date Between #" & [Start Date] & "# And #" & [End Date] & "#")

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    You already told us that. Did you try the suggestion?
    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.

  5. #5
    KRS@WAC is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    3
    Tried adding the brackets around [Date], made no difference. The report generates, this field is blank then after a few seconds, "#ERROR" populates. Could the delay be significant?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Domain aggregate functions are known to perform slowly on large datasets.

    If no records meet the criteria function should return 0.

    I am afraid not able to determine cause without directly viewing db.
    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.

  7. #7
    beilstwh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2018
    Posts
    11
    Actually if it can't find any rows it returns null not zero which would display as #error. Wrap the dsum inside an NZ function so if it is null it sets the sum to 0

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Oops, correct.

    DCount() would return 0.

    Good catch beilstwh.

    So now the question is whether or not there are records that should meet the criteria?
    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.

  9. #9
    beilstwh is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jan 2018
    Posts
    11
    I would set a break point at the dsum and see what the variables start date and end date contains and then run a query against the dataset using the same filter conditions

  10. #10
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    In addition to bracketing Date as June suggested, you should also bracket "[Total Loans]" as you have a space in the name.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    That does seem to be needed, moke, but if you test, it will work without the brackets on the table/query name. Weird, right! But certainly won't hurt to use.

    Really advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.
    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. Relationships working but no longer shown????
    By jimaccessnovice in forum Database Design
    Replies: 5
    Last Post: 02-15-2018, 05:25 PM
  2. Replies: 10
    Last Post: 07-21-2017, 09:32 AM
  3. Email from Access no longer working
    By Gina Maylone in forum Access
    Replies: 4
    Last Post: 10-12-2016, 06:46 AM
  4. DSUM Where Expression not working
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 02-23-2015, 09:41 PM
  5. Print button no longer working
    By kris335 in forum Programming
    Replies: 6
    Last Post: 09-28-2012, 08:56 PM

Tags for this Thread

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