sub report won't show if no records are returned

G

Guest

Hi
I have a report with a sub report. The parent report is grouped by month.
The sub report is displayed for each month with the relevant records for that
month. My problem is that if the sub report returns no records then the sub
report won't show other controls that are on the sub report that are
unrelated to the return of records ie labels. Does anyone have any ideas
Cheers
 
M

Marshall Barton

johnoxy said:
I have a report with a sub report. The parent report is grouped by month.
The sub report is displayed for each month with the relevant records for that
month. My problem is that if the sub report returns no records then the sub
report won't show other controls that are on the sub report that are
unrelated to the return of records ie labels. Does anyone have any ideas


Maybe you don't really need to use a subreport. Can you get
a reasonable result by just using a main report with Sorting
and Grouping instead?

If you really need to use a subreport, then, because there
is no way to display any part of subreport that has no data,
you need to put the labels,etc (or a copy) on the main
report. If you have to copy the labels on the main report,
then put them on top of the subreport (so they are in the
right place when the subreport is empty). Then you need to
make them visible only when the subreport has no data using
code in the section's Format event:

Me.label1.Visible = Not Me.subreportcontrol.Report.HasData
Me.label2.Visible = Not Me.subreportcontrol.Report.HasData
. . .

If you have a lot of these labels, etc, post back and I'll
explain how to use a loop so you don't have a long list of
the above statements.
 

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