Checking for data in a subreport

  • Thread starter Thread starter anthony
  • Start date Start date
A

anthony

I have a report (let's call it rptMain) which contains a subreport
(let's call that rptSub). rptMain has a header which always contains
data. rptSub is placed in the detail section of rptMain. rptSub may,
or may not contain data. I need to instruct rptMain not to print any
pages where rptSub contains no data. I've seen from past postings that
if a subreport contains no data, then it doesn't actually exist which
would make it difficult to check whether a field in rptSub had
anything in it. I don't know whether it's possible to check for the
existence of data/controls etc within the detail section of rptMain.
If it is, I don't know how to do it. Having, somehow, determined that
a particular page produced by rptMain had no data in its detail
section (ie in rptSub), I then need to know how to prevent that page
from printing - perhaps through the page.visible property?

Advice very gratefully received. Many thanks

Anthony
 
anthony said:
I have a report (let's call it rptMain) which contains a subreport
(let's call that rptSub). rptMain has a header which always contains
data. rptSub is placed in the detail section of rptMain. rptSub may,
or may not contain data. I need to instruct rptMain not to print any
pages where rptSub contains no data. I've seen from past postings that
if a subreport contains no data, then it doesn't actually exist which
would make it difficult to check whether a field in rptSub had
anything in it. I don't know whether it's possible to check for the
existence of data/controls etc within the detail section of rptMain.
If it is, I don't know how to do it. Having, somehow, determined that
a particular page produced by rptMain had no data in its detail
section (ie in rptSub), I then need to know how to prevent that page
from printing - perhaps through the page.visible property?


The "correct" way to avoid displaying main report data is to
filter those records out of the main report's record source
query. This way there will be nothing for the main report
to display and the subreport will not come into play.

Without knowing how your main and sub reports are linked all
I can sugest is that you create a Distinct query that users
an inner join on the linking fields. Do not add any fields
from the subreport's table to this query's field list.
 
The "correct" way to avoid displaying main report data is to
filter those records out of the main report's record source
query. This way there will be nothing for the main report
to display and the subreport will not come into play.

Marsh, that has been amazingly helpful. Thank you so much. This report
is fiendishly complicated (for me!) but initial testing, having done
what you suggest, looks promising

Anthony
 
Back
Top