#error equals 0 (1 Viewer)

mgui

Registered User.
Local time
Today, 14:14
Joined
Nov 18, 2017
Messages
10
I am creating a financial report in Access 2007. My report has a subreport. I am trying to pull subtotals from the subreport. Some of my fields from the subreport do not have any data, so I am receiving an #error in the text box. I need a code to turn the #error into 0. I currently have the following code in the text box =[Donations].[Report]![txtTotalsDonation Amount]

I have attached two screenshots of what I am doing.

Please help me get rid of #error and replace it with 0
 

Attachments

  • report.JPG
    report.JPG
    96.4 KB · Views: 102
  • code.jpg
    code.jpg
    101.1 KB · Views: 108

June7

AWF VIP
Local time
Today, 13:14
Joined
Mar 9, 2014
Messages
5,423
What is expression in txtTotalsDonationsAmount?

If you want to provide db for analysis, follow instructions at bottom of my post.
 

mgui

Registered User.
Local time
Today, 14:14
Joined
Nov 18, 2017
Messages
10
I do not know anything about writing code. I got the code I am using from a YouTube video. I need some to tell me the exact code to use.
 

June7

AWF VIP
Local time
Today, 13:14
Joined
Mar 9, 2014
Messages
5,423
Can try:

=IIf(IsError([Donations].[Report]![txtTotalsDonation Amount]), 0, [Donations].[Report]![txtTotalsDonation Amount])

Really need to find out why error occurs and fix code.
 
Last edited:

moke123

AWF VIP
Local time
Today, 17:14
Joined
Jan 11, 2013
Messages
3,852
Some of my fields from the subreport do not have any data
If you are trying to add fields together and one of them is null you'll get null.
Null + anything is null. The solution is to wrap a null with the Nz Function which turns a null into the given value.

Code:
Nz(YourField,0)
 

Users who are viewing this thread

Top Bottom