Calculations in Report

  • Thread starter Thread starter manchery
  • Start date Start date
M

manchery

Hi,
I have a report with two subreports. In both subreport
there is a field to get the total records (sum(*)). In
the main report I have a field which is = subreport1!sum -
subreport2!sum. If any of the subreport is empty then i am
getting Error.. how can i do this please
 
Manchery try this. Also I would change the name of your controls from sum
to sum-thing else because sum is a reserved word in access.

= Nz(subreport1!sum,0) - Nz(subreport2!sum,0)
 
Reggie said:
Manchery try this. Also I would change the name of your controls from sum
to sum-thing else because sum is a reserved word in access.

= Nz(subreport1!sum,0) - Nz(subreport2!sum,0)


Nz won't work for this Reggie, if the subreport has no
records, then the sum control will not exist so you can not
test it for Null. See my answer to Manchery for a way that
deals with this situation.
 
manchery said:
Hi,
I have a report with two subreports. In both subreport
there is a field to get the total records (sum(*)). In
the main report I have a field which is = subreport1!sum -
subreport2!sum. If any of the subreport is empty then i am
getting Error.. how can i do this please


You can test if the subreport has any records by using this
kind of expression:

=IIf(subreport1.Report.HasData, subreport1.Report.sum, 0) -
IIf(subreport2.Report.HasData, subreport2.Report.sum, 0
 
Thank you so much Mr. Marshall
You are right the other answer didn't work. But still I
wish to thank Reggie for the valuable time/effort spent
for answering my question.. ....

Regards

Manchery
 
Back
Top