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

How to change a 'Section' SubReport's Printer using RAP

edited April 2008 in RAP
Hi

Delphi 6 Pro (SP2)
Report Builder Enterprise Addition 7.04
Windows XP Pro


I have designed a report using the DADE with a 'Section' SubReport
within the Details Band on the main report. Just before the subreport
is printed I need to change the Printer Name. If this is possible I
assumed I would need to enter something like the code below within the
OnPrint event of the sub-report but it does not seem to make any
difference.


If Sites['SitePrefix'] = 'A' then
Report.PrinterSetup.PrinterName := 'Default'
else
Report.PrinterSetup.PrinterName := 'Lexmark Z51 Color Jetprinter';


How can I do this ? I think I may need to access the Page's
PrinterSetup or something via a pass-through function but any guidance
would be appreciated.

Thanks

Stuart

--

Comments

  • edited April 2008


    - for the section subreport, make sure you have subreport.NewPrintJob set to
    true and ParentPrinterSetup to False.

    - now subreport.Report.PrinterSetup.PrinterName will control the
    destrination for the section.

    - There will be a timing issue involved as well. If you set the PrinterName
    too late it will be ignored. I would try using the main report's
    detailband.BeforePrint event.

    I notice you are using a very old version of RB. Please consider upgrading
    to RB 10.



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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2008
    Hi Stuart,

    Section subreports have the ability to create their own print jobs. Be sure
    you have the Subreport.NewPrintJob property set to True and the
    Subreport.ParentPrinterSetup property set to False. Then in an event that
    fires before the subreport prints (such as the Band.BeforePrint of the main
    report), set the printer name of the subreport using the
    Report.PrinterSetup.PrinterNames list. This will ensure that you have the
    correct printer name. Something like the following...

    procedure DetailBeforePrint;
    begin
    Subreport1.Report.PrinterSetup.PrinterName :=
    Report.PrinterSetup.PrinterNames[4];
    end;

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2008

    Thanks

    Just what I needed, works great.

    Stuart

    P.S. Although this issue was with 7.04 I am proud to be a registered
    user of 10.07.
This discussion has been closed.