David wrote:
Folks,
I have four subreports in a report in the detail section. I suppose I
could move them to the footer of the report. Anyway, if any of them
have data, I want the main report to force a page break. I am trying
to use the "hasdata" property for the subreports, but I am getting the
generic error indicating property not available for object.
How does one tell the main report (using VBA) not to throw in a page
break unless the subreport has data? There has to be an easy set of
code for this. Thanks.
David
Don't forget that you have to refer to the report property of the
subreport when determining whether or not the subreport has data, i.e.
MySubreport.Report.HasData
That being said, I am assuming you could put a page break control at
the end of your detail section and something like the following in the
detail_format event of your main report to force a page break if any of
the reports have data:
If MySub1.Report.HasData Or _
MySub2.Report.HasData Or _
MySub3.Report.HasData Or _
MySub4.Report.HasData Then
PageBreak.Visible = True
Else
PageBreak.Visible = False
End If
Note that 'telling the main report NOT to throw in a page break' if the
subreports have no data is something different than telling the main
report to throw in a page break if the subreports do have data and
would be a much more complicated affair if it could even be achieved at
all.
HTH,
Bruce