#error on report/subreport when field is empty

G

Guest

I have a report that also includes about 7 sub-reports. It is basically a
"roll-up" expenditure report. Each sub report totals its particular
expenditure in the Report Footer. I then placed each into a "master report"
and located them in the Report Footer. Everything there works fine. I then
try to have a "total" calculation that totals all expenditures. My problem
(of course) is when there are no expenditures for any particular section. I
will receive a #error message if any area is missing a expense. Below is the
"total" formula that I am using. Any help would be appreciated. My knowledge
of this stuff is limited at best.
Thanks

=[Text0]+[cg report].Report!Text0+[cl report].Report!Text0+[gc
report].Report!Text0+[le
report].Report!Text0+mdreport.Report!Text0+ncreport.Report!Text0+psreport.Report!Text0+pwreport.Report!Text0
 
A

Allen Browne

Yes, if there are no records in a subreport, Access shows nothing, and then
referring to the non-existent control in the subreport results in #Error.

To work around that, test the HasData property of the Report in the
subreport control:
=IIf([Sub1].[Report].[HasData], Nz([Sub1].[Report].[Text1],0), 0)
 
G

Guest

I'm not sure what you are talking about "...Report in the subreport control."
I can't find "HasData" property listed anywhere. How can I find where to
write this iif statement, and do I have to do it for each subreport in 1 iif
statement? If so, do I just type .... or....? Thanks. I told you I was a
little slow.

Allen Browne said:
Yes, if there are no records in a subreport, Access shows nothing, and then
referring to the non-existent control in the subreport results in #Error.

To work around that, test the HasData property of the Report in the
subreport control:
=IIf([Sub1].[Report].[HasData], Nz([Sub1].[Report].[Text1],0), 0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Mike said:
I have a report that also includes about 7 sub-reports. It is basically a
"roll-up" expenditure report. Each sub report totals its particular
expenditure in the Report Footer. I then placed each into a "master
report"
and located them in the Report Footer. Everything there works fine. I then
try to have a "total" calculation that totals all expenditures. My problem
(of course) is when there are no expenditures for any particular section.
I
will receive a #error message if any area is missing a expense. Below is
the
"total" formula that I am using. Any help would be appreciated. My
knowledge
of this stuff is limited at best.
Thanks

=[Text0]+[cg report].Report!Text0+[cl report].Report!Text0+[gc
report].Report!Text0+[le
report].Report!Text0+mdreport.Report!Text0+ncreport.Report!Text0+psreport.Report!Text0+pwreport.Report!Text0
 
A

Allen Browne

Open the main report in design view.

Right-click the edge of the subreport, and choose Properties.
On the Other tab of the properties box, you see the name of the subreport
control.
This is the name you need to use. In the example, we assumed it is "Sub1".
It might be different from the name of the report that gets loaded into the
control (its Source Object.)

To refer to the report in the subreport control, add the .Report bit.

This is similar to the ".Form" bit for referring to the form in a subform
control. More info:
http://allenbrowne.com/casu-04.html

The subreport control does not have a HasData property.
The report has that property.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Mike said:
I'm not sure what you are talking about "...Report in the subreport
control."
I can't find "HasData" property listed anywhere. How can I find where to
write this iif statement, and do I have to do it for each subreport in 1
iif
statement? If so, do I just type .... or....? Thanks. I told you I was a
little slow.

Allen Browne said:
Yes, if there are no records in a subreport, Access shows nothing, and
then
referring to the non-existent control in the subreport results in #Error.

To work around that, test the HasData property of the Report in the
subreport control:
=IIf([Sub1].[Report].[HasData], Nz([Sub1].[Report].[Text1],0), 0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Mike said:
I have a report that also includes about 7 sub-reports. It is basically
a
"roll-up" expenditure report. Each sub report totals its particular
expenditure in the Report Footer. I then placed each into a "master
report"
and located them in the Report Footer. Everything there works fine. I
then
try to have a "total" calculation that totals all expenditures. My
problem
(of course) is when there are no expenditures for any particular
section.
I
will receive a #error message if any area is missing a expense. Below
is
the
"total" formula that I am using. Any help would be appreciated. My
knowledge
of this stuff is limited at best.
Thanks

=[Text0]+[cg report].Report!Text0+[cl report].Report!Text0+[gc
report].Report!Text0+[le
report].Report!Text0+mdreport.Report!Text0+ncreport.Report!Text0+psreport.Report!Text0+pwreport.Report!Text0
 

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