Detect Presence Of Subreports

G

Guest

I've got a main report with two subreports. There's no guarantee that a child
record will exist in the subreports for each parent record in the main
report. Each subreport has a "total" field in the footer that I want to
reference on the main report. In a situation where there is not a subreport,
I want a 0 to be carried forward.

The following is the control source of a text box on the main form. However,
it generates an "#Error!" message whether or not there is a subreport.

rptMW_ACCOUNTS_CLOSED is the name of the subreport, and txtTOTAL_DEDUCTIONS
is the name of the text field I want to bring over.

=IIf(IsNull([rptMW_ACCOUNTS_CLOSED]),0,[rptMW_ACCOUNTS_CLOSED]![txtTOTAL_DEDUCTIONS])

Any help would be appreciated.
 
M

Marshall Barton

MDW said:
I've got a main report with two subreports. There's no guarantee that a child
record will exist in the subreports for each parent record in the main
report. Each subreport has a "total" field in the footer that I want to
reference on the main report. In a situation where there is not a subreport,
I want a 0 to be carried forward.

The following is the control source of a text box on the main form. However,
it generates an "#Error!" message whether or not there is a subreport.

rptMW_ACCOUNTS_CLOSED is the name of the subreport, and txtTOTAL_DEDUCTIONS
is the name of the text field I want to bring over.

=IIf(IsNull([rptMW_ACCOUNTS_CLOSED]),0,[rptMW_ACCOUNTS_CLOSED]![txtTOTAL_DEDUCTIONS])


You need to use the HasData property:

=IIf([rptMW_ACCOUNTS_CLOSED].Report.HasData,
[rptMW_ACCOUNTS_CLOSED].Report![txtTOTAL_DEDUCTIONS], 0)
 

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