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

Multi-Page report - ReportResidentAssessments.pas (0/1)

edited October 2008 in Subreports
I've just updated to RB11 (with Delphi 2007) and it "appears" to have
broken some existing code. I said "appears" because I don't think I
have changed anything beyond opening and closing the report.

I wrote about this back on 1-Feb-2002 and with your help I have had it
working. I based my code on some sample code that you emailed me.
Essentially I have one master table which has 50+ columns (It has the
answers to a survey). There are to many fields to fit on one page. So
I designed a report with 3 subreports. Each sub report represents one
page of the survey and has a subset of the columns.

What I need to have printed is the following:
Survey 1
Page 1 of Survey 1
Page 2 of Survey 1
Page 3 of Survey 1
Survey 2
Page 1 of Survey 2
Page 2 of Survey 2
Page 3 of Survey 2
etc....

Without any special code, what I get is:
Page 1 of Survey 1
Page 1 of Survey 2
Page 2 of Survey 1
Page 2 of Survey 2
Page 3 of Survey 1
Page 3 of Survey 2

My Basic Routine to Print is as Follows:
if dpData.DataSource.DataSet.RecordCount > 0 then
begin
//
// Initialize SubReport Page Counts
//
FFirstReportPageCount := 0;
FSecondReportPageCount := 0;
FThirdReportPageCount := 0;

//
// Generate Report to Cache and Reorder Pages
//
PrintToCache;
ReorderPages;

//
// Now Actually Print The Report
//
if ADest = dtScreen then
begin
{$IFDEF Debug}
CodeSite.SendMsg( 'Printing to Screen' );
{$ENDIF} // Debug
AReport.AllowPrintToFile := False;
AReport.PrinterSetup.Copies := 1;
AReport.PrinterSetup.DocumentName := 'ProCor ' +
rptTitle2.Caption;
AReport.ShowPrintDialog := False;
AReport.TextFileName := '';
AReport.DeviceType := ADest;
AReport.Print;
end
end

I've checked and the subreport page counts are being created
correctly. If I comment out the routines PrintToCache and ReorderPages
then the report prints but not collated the way I need it. If I
comment out only the Routine ReorderPages, the report prints just not
collated the way I need it.

When I use the routines PrintToCache and ReorderPages and print the
report I get no pages in the print preview and an Access Violation
when I close.

I have attached my code.
---
Luke Miller
ResCorSoft, Inc.

"Feliz es el hombre que ha hallado sabiduría,
y el hombre que consigue discernimiento"

Comments

This discussion has been closed.