I don't know how you can do this with a subreport, but you could do this
with a report that includes grouping.
Create a query to combine your report level records with your subreport
records. In the relationship between the header table XXX and subrecord
table YYY make sure the relationship is the type "include all records from
table XXX and any related records from table YYY". Then build your report
on this query and add grouping on the record level ID field.
Then add an unbound field (called say "counter") on the group header with
the expression "=Count([YYY_ID])" in the datasource where YYY_ID is the key
field in the YYY table. This field will be 0 when there are no subrecords.
Add a page break (called say "newpage") at the bottom of the group header
(under the fields to be shown), and in the OnFormat event put for the group
header you add code like...
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
If counter = 0 Then
newpage.Visible = False
Else
newpage.Visible = True
End If
End Sub
So the report should then show the header level record and if there are
subrecords there will be a page break then the subrecords are printed. If
there are no subrecords then no page break.
Doug
Kathy Webster said:
I posted this in reports, but no one answered:
How can I create a page break before the subreport if and only if the
subreport has data?
Some records will have no data in the subreport, and I don't want an
unnecessary page break in those instances.
Thank you,
Kathy