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

Printing multiple copies

edited December 2006 in Devices
Hi,

Situation:
Report of multiple Contracts:
Group on ContractNbr (StartNewPage)
Use of Master(Contract)==> Detail (1-n Annexes)
Report output
--------------
Contract1/copy1
SubReport(Annex) 1/1
Contract1/copy2
==> Subreport(Annex) not need
Contract2/copy1
SubReport(Annex) 1/1
Contract2/copy2
==> Subreport(Annex) not need

Solution tried:
--------------
Add a field CopyNbr in the MasterDatasource and copy each record N times.
(N= Copies in PrinterSetup or PrintDiaolog)
Dataset looks like
Contract1,CopyNbr1
Contract1,CopyNbr2
Contract2,CopyNbr1
Contract2,CopyNbr2
Contract3,CopyNbr1
.....
When printing : if Master.CopyNbr <> 1 then SubReport.Detailband.Visible :=
False
This should work (already tried this in other situations)

Following steps are being executed:
FormProperty NbrCopies = 2
Preview Report (Copies always = 1)
PreviewForm.Print => Copies = 2 in PrintDialog
FormProperty NbrCopies = Printdialog.Copies
ppReportBeforePrint => manipulate the MasterDataset as descriped above.

procedure TfrmRepEmpContractA.ppRepEmpContractABeforePrint(
Sender: TObject);
begin
if (ppRepEmpContractA.DeviceType <> dtScreen)
then dmReports.AddReportCopies(dmReports.cdsRepEmpCttGlobal,
FNumberOfCopies);
ppRepEmpContractA.PrinterSetup.Copies := 1;
ppDBPipelineCttGlobal.First;
end;

After clicking the Print button in the PrintDialog the program starts
generating output to the printer
and DOES NOT STOP. (ex. Report of 6 masterrecords cancelled after 90 pages
sent to printer)
Which Event or Method could generate this endless loop ?
Where can I manipulate the MasterDataset without having side-effects ?
Or am I missing something else ?

I am using Delphi 7 RB 9.02

Tnx in advance,

Eddy Van Steenbergen

Comments

  • edited December 2006
    Hi Eddy,

    I'm a bit unclear why you need to alter your master dataset during the
    report generation. Would it be possible to do this before calling
    Report.Print? It is never good to alter the data the report is using during
    the generation process. The altering of the dataset during generation is
    most likely the reason you are getting infinite pages. This is most likely
    confusing the report engine in some way and causing issues.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2006
    I implemented a custom Form with extra Print options and also the number of
    copies.
    This way I can duplicate the records before report generation.
    When using the Print-button in the Report preview I set the edtCopies field
    Readonly.
    The Report.PrintSetup.Copies is always set to 1.
    I knew it was a bit risky altering the dataset during report generation but
    hoped there would be an alternative in the Report itself.

    Thanks for the information.
    Regards
    Eddy

  • edited December 2006
    One option would be to take complete control over the print button in the
    previewer so you could process the dataset before the report is printed.
    Note that if you override the OnClick event of the print button, you will
    need to add the logic to print the report yourself.

    uses
    ppPrvDlg;

    TppPrintPreview(ppReport1.PreviewForm).PrintButton.OnClick

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.