Detect Presence Of Subreports

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