Adding amt from subreport

  • Thread starter Thread starter David Chase
  • Start date Start date
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
 
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.
 
Back
Top