Calculations in Report

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
 
R

Reggie

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)
 
M

Marshall Barton

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.
 
M

Marshall Barton

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
 
M

manchery

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
 

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