Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Formatting a Report for Printing...

edited April 2002 in General
When a user clicks the print button on my report, I want to print the report
with all subreports expanded. I'm sure I need to use the ExpandDrillDowns,
but I'm not sure what event to put it in?

Comments

  • edited April 2002
    You can set the ExpandAll property of the subreport to True before calling
    Print on the report. You can also take a look at the sample demo below of
    how to modify the print preview screen to give the end user the ability to
    control which subreports print expanded.

    http://www.digital-metaphors.com/tips/DrillDownExpandAll.zip

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002

    "Alexander Kramnik (Digital Metaphors)" wrote
    in message news:3cbd8a50$1@dm500....
  • edited April 2002
    I'm not sure I understand. I'm not talking about printing the report to the
    screen. I'm talking about, when the user is looking at a report in the
    report viewer, and then click on the report viewer's Print (to a printer)
    button. At this time, I want to expand sub reports, so that the the printed
    (on paper) report, shows all of the information from the sub reports.

    I'm just not sure what event gets triggered when the user clicks on that
    Report Viwer. I was looking for an OnPrint event, but the closest seems to
    be 'OnPrintDialogCreate' and 'OnPrintDialogClose'. So should I use one of
    those events?

    Also, what is the benefit of manually setting the ExpandAll property of all
    subreports to true instead of calling 'ExpandDrillDowns'.

    In the OnPrintDialogCreate event, I called ExpandDrillDowns on my report,
    followed by a 'PrintToDevices' (as suggested in the help). When I tested
    it, it began printing infinite pages. The first report printed was
    formatted correctly with all subReports expanded, but each of the addtional
    reports printed were printed with the subReports closed. I'm not sure where
    I went wrong.

    --Chris

    "Alexander Kramnik (Digital Metaphors)" wrote
    in message news:3cbd8a50$1@dm500....
  • edited April 2002
    The reason that you are getting infinite pages is because you are calling
    Print yourself and when the print dialog closes Print is called again. Each
    of these will recurse into further Print calls. There are two ways to expand
    all drill down only when printing to the printer.

    Method 1: Call ExpandDrillDowns in OnPrintDialogClose (do not call Print
    though as it will be called after the dialog closes.)

    Method 2: Call ExpandDrillDowns in the report's BeforePrint event
    conditionally, ie.

    if (ppReport1.DeviceType = 'Printer') then
    ppReport1.ExpandDrillDowns;

    There is no benefit in setting the ExpandAll property. In actuality,
    ExpandDrillDowns does the same thing, it sets ExpandAll for all the
    subreports. The difference is that it also reset's the report.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002
    Okay, it correctly prints out the view with all subreports expanded.
    However now I have the problem that you can no longer manually control the
    expand and collapse by clicking on the drilldown component.

    I've read that this is solved by doing a collapse all, but If my user has
    specific subReports open, I want to be able to print it with all expanded,
    but when they return to the report, I want them to have only expanded the
    ones that they had expanded before hitting the print button. And I want
    them to have manual drilldown control again.

    How can I acheive this

    --Chris


    "Alexander Kramnik (Digital Metaphors)" wrote
  • edited April 2002
    You will have to manually handle 'remembering' which reports were expanded
    before expanding them all for printing. You can do this by keeping a list or
    an array of value and marking the ones that the user expands before
    printing. After printing completes you iterate over that list and restore
    only the ones the user has expanded. See the down below for an example:

    http://www.digital-metaphors.com/tips/ExpandAllWithRestore.zip

    heers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.