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

Multiple reports to same printer

edited August 2001 in General
I have ten existing reports that I need to send to the printer. I only want
a printer dialog to appear once and I want to user to see a progress bar and
be able to cancel printing at any time.

The alternatives that I know of so far are:

1. Create a new master report and attach the existing 10 reports to the
master as subreports. A friend of mine has indicated to me that using this
approach has a major drawback. He said that once I attach a report using
the designer, any changes that I need to make to the reports will have to be
done in 2 places. Is this true?

2. Create a new master report. At runtime, attach the individual (10)
reports to the master report. Although this seems like a good option, I am
concerned about alignment, difficulty and other issues that may arise.

3. Create a PrinterDevice, allow the user to set the printer properties and
then dynamically assign the printer device to each report before running
them. The problem with this solution is that the user want to see a
progress bar and be able to cancel printing at any time. I know that I can
probaby handle this through the reports events, but it may get ugly.


Can anyone commit on their experiences and/or alternatives that I have not
listed? I am still a novice to ReportBuilder so code snippits are
definately welcome.

Kevin

Comments

  • edited August 2001
    > 2. Create a new master report. At runtime, attach the individual (10)
    am


    I do this all the time. Makes life easier. And it is not hard to try. Here
    is the code for doing it (rewrite it to fit your own app).

    procedure LoadSubReport(aReportID: integer);
    var
    lSubReport: TppSubReport;
    lMS: TMemoryStream;
    lppImage: TppImage;
    lppPageStyle: TppPageStyle;

    begin
    //create the report
    lSubReport := TppSubReport.Create(frmTables);
    lSubReport.Band := frmTables.ppReport.DetailBand;// ppDetailBand1;

    lSubReport.CreateReport(TppReport(frmTables.ppReport.DetailBand.Report));
    lSubReport.PrintBehavior := pbSection;
    lSubReport.ParentPrinterSetup := False;

    //load the report
    lMS := TMemoryStream.Create;
    try
    if not frmTables.tblReports.Locate('Report_ID', aReportID, []) then
    raise exception.Create(Format('Report_ID not found. [%d]',
    [aReportID]));

    frmTables.tblReportsTheReport.SavetoStream(lMS);
    lMS.Position := 0;
    lSubReport.Report.Template.LoadFromStream(lMS);
    finally
    lMS.Free;
    end; // try/finally
  • edited August 2001
    Thanks Ed. I will give it a try.

    Kevin



This discussion has been closed.