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

Printing subreports

edited July 2008 in Subreports
I have a header and footerless report. In the detail of the report are 2
subreports. Everything works nicely.

I'm trying to change it so that subreport1 prints from tray 1 of the
selected printer and subreport2 prints from tray 2 of the selected printer.

I have tried the following code, adapted from a forum post elsewhere, but
I don't know why all the pages are printing from the same print tray:

procedure SubReport1OnPrint;
var
lsBinName: String;
begin
lsBinName := Report.PrinterSetup.BinNames[0];
Report.PrinterSetup.BinName := lsBinName;
end;


procedure SubReport2OnPrint;
var
lsBinName: String;
begin
lsBinName := Report.PrinterSetup.BinNames[1];
Report.PrinterSetup.BinName := lsBinName;
end;

Has anyone managed to programatically change the print tray used for
subreports?



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited July 2008

    If you have two subreports set to PrintBehavior of pbSection, then each
    subreport can have a separate printersetup.

    You can set subreport.ParentPrinterSetup to False.

    a. At design-time you can access the workspace for the subreport and then
    use the File | PageSetup dialog to configure the bin.

    b. Or programmatically you can configure the subreport.Report.PrinterSetup
    properties.




    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited July 2008
    I used Suggestion A so I can now send pages to different trays of a known
    printer, but if I change the target printer at runtime the job just goes
    to the default printer. I'd like to redirect pages to different trays of
    whatever printer the user just decided to print from.

    I'm having trouble with Suggestion B. Would you please provide a sample
    procedure? My syntax seems to be out and I don't know why.




    --- posted by geoForum on http://delphi.newswhat.com
  • edited August 2008

    mySubreport.ParentPrinterSetup := False;
    mySubreport.Report.PrinterSetup.BinName :=
    mySubreport.Report.PrinterSetup.BinNames[0];


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.