Help with getting value from subreport

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report "rptHousing2" with a
subform "rptHousingSub2". On the subform I have a
control that counts the number of records in the
subreport. The name of this control is CountRooms. Now I
am trying to sum the values from this control on the main
report.

I have a control on the main report:
=Sum([rptHousingSub2].Reports!CountRooms)
which I built with the code builder results in asking me
for a parameter value when I try to print the report.

What am I doing wrong. BTW, "rptHousingSub2" is the name
of the subreport control as well as the name of the
subreport.

Thanks,

Sandra Grawunder
 
Presumably you already have the count in the CountRooms control on the
subreport.

The =Sum() part is not going to work, so we will drop that. You can use a
Running Sum property of the text box on the main report if that is what you
need to achieve.

Use ".Report" (without the S) to refer to the report in the subreport
control. Try:
=[rptHousingSub2].[Report]![CountRooms]

That should work until you hit a record in the main report that has no
matches in the subreport. To get around that, you need to test the HasData
property of the report in the subreport control. Try:
=IIf([rptHousingSub2].[Report].[HasData],
Nz([rptHousingSub2].[Report]![CountRooms],0), 0)
 
Back
Top