Adding amt from subreport

D

David Chase

I have a report and an embedded subreport in a break footer. In the break
footer I have totals that sum up detail records and also add in amounts from
the linked subreport. If the linked subreport has at least 1 record in it
the totals are fine. However, if the subreport does not contain any records
I get #Error in the total field on the main report.

I have tried several things like using IIF(IsNull(...) etc. but I still get
an error. The report total field contains something like this:

=[TotalDetail]+IIf(IsNull(Reports!MainReport!subreport.report!field),0,Repor
ts!MainReport!subreport.report!field)

originally I did not have the IsNull and I got the #Error which I
understand, but why now? Thanks.

David
 
A

Allen Browne

The issue is that if the subreport has no data, referring to the
(non-existent) text box causes an error.

The solution is to test the HasData property of the report in the subreport
control:
=IIf([subreport].Report.HasData, Nz([subreport].Report![Field], 0), 0)

Replace the bits in square brackets with your actual names.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top