#error equals 0 (1 Viewer)

mgui

Registered User.
Local time
Yesterday, 17:35
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

June7

AWF VIP
Local time
Yesterday, 16:35
Joined
Mar 9, 2014
Messages
2,768
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
Yesterday, 17:35
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
Yesterday, 16:35
Joined
Mar 9, 2014
Messages
2,768
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
Yesterday, 20:35
Joined
Jan 11, 2013
Messages
1,211
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)
 

mgui

Registered User.
Local time
Yesterday, 17:35
Joined
Nov 18, 2017
Messages
10
Thank you, your code worked!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom