Results 1 to 7 of 7
  1. #1
    Bernard is offline Novice
    Windows 10 Access 2013
    Join Date
    Sep 2015
    Posts
    7

    access 2013 How make the SUM of three fields in a report return " " if the result is zero


    I am using the following expression in a report and if the SUM comes to zero, I want spaces NOT zero
    the expression is: =Sum(([payment 1])+Nz([pmnt2])+Nz([pmnt3]))

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Code:
    IIF(Sum(([payment 1])+Nz([pmnt2])+Nz([pmnt3]))=0,"",Sum(([payment 1])+Nz([pmnt2])+Nz([pmnt3])))

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    FYI, you could use the format property of the textbox on the report instead of a formula. Oh, and personally I'd be explicit with the Nz() function: Nz(pmnt2, 0).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Bernard is offline Novice
    Windows 10 Access 2013
    Join Date
    Sep 2015
    Posts
    7
    Thanks for your answer Joe. That very much looked like the solution but when I copied your code and pasted it in the total field and tried to run the report, I got the error message "Error Extra ) in query expression...etc,etc"
    I tried again knocking off the last ')', but got the same result

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    pair off the brackets to find the missing or extra ones.

    Also, be aware it is not a good idea to return either a string or a number - it can cause problems down the line - return null instead of "" for zero or convert your number to a string for consistency

  6. #6
    Bernard is offline Novice
    Windows 10 Access 2013
    Join Date
    Sep 2015
    Posts
    7
    I have tried to pair off all the brackets but cannot find anything wrong, and I'm still stuck with zeros I don't want.
    I am a novice , but the suggested expression 'IIF(Sum(([payment 1])+Nz([pmnt2])+Nz([pmnt3]))=0,"",Sum(([payment 1])+Nz([pmnt2])+Nz([pmnt3])))
    seems a bit long. Perhaps there is a shorter way of returning spaces in a report if result = zero in this particular sum?

  7. #7
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Post # 3 and post # 5.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-06-2016, 01:18 PM
  2. Replies: 17
    Last Post: 02-13-2015, 06:24 AM
  3. Replies: 1
    Last Post: 01-05-2013, 10:46 PM
  4. Replies: 2
    Last Post: 11-14-2012, 04:47 PM
  5. Replies: 3
    Last Post: 06-29-2012, 08:54 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