Code To Prevent Printing A Subreport

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I have a subreport that can contain one or two pictures per page. The
subreport is similar to an appendix to the main report. The recordsource
contains a field "IncludeInReport" (Yes/No) for each picture record. What
code do I use and where does it go to prevent printing the subreport if
there are no picture records marked "Yes" in the "IncludeInReport" field?

Thanks,

Tom
 
Create a query to use as the RecordSource of your subreport.

In the Criteria row of the query, under the IncludeInReport field, enter:
True
 
Allen,

Thanks for your response!

Please reread my post. I want to know how and where to code to prevent
printing the subreport when there are no records marked Yes in the
IncludeInReport field.

Thanks,

Tom
 
Tom, I would never consider doing that in code, when you could elimiate the
records in the *query* that the subreport is based on, so that no code is
needed.

Is there a special reason you wish to use code?
 
The subreport has titles and a logo. It prints when there are no records
marked Yes in the IncludeInReport field.

Tom
 
That doesn't happen in my copy of Access.
If there are no records in the subreport, nothing gets printed.

What you are asking for can be done by testing the HasData property of the
report in the subreport control, in the Format event of the main report
section, or by performing a DLookup() on related records to see if there are
any, and then toggling the Visible property of the main report section that
contains the subreport or setting the runtime properties PrintSection and
MoveLayout. However, it makes no sense to me to do it that way.
 
Back
Top