Set Report.PrinterSetup.Copies depending of data
Hi,
I have a Invoice Report and I want to set copies depending of the customer.
I have two options to change the copies:
1.- Directly in the report with
Report.PrinterSetup.Copies
2.- With a pass-through funtction which made the following:
frmEndUserInterbase.ppReport1.PrinterSetup.Copies := liCopias;
Problem here is that I don't know in which event should I put one of the
options above.
They both work in events OnCreate or OnGetAutoSearchValues but at that
moment the Field customer is not yet filled. I guess that the DataPipeLine
hasn't been opened.
In which event should can I change the number of copies taking into account
the data in the report? Can I do it with Report.PrintDialog ... ?
Thanks,
Jose Maria Sanmartin
I have a Invoice Report and I want to set copies depending of the customer.
I have two options to change the copies:
1.- Directly in the report with
Report.PrinterSetup.Copies
2.- With a pass-through funtction which made the following:
frmEndUserInterbase.ppReport1.PrinterSetup.Copies := liCopias;
Problem here is that I don't know in which event should I put one of the
options above.
They both work in events OnCreate or OnGetAutoSearchValues but at that
moment the Field customer is not yet filled. I guess that the DataPipeLine
hasn't been opened.
In which event should can I change the number of copies taking into account
the data in the report? Can I do it with Report.PrintDialog ... ?
Thanks,
Jose Maria Sanmartin
This discussion has been closed.
Comments
Try using the AfterOpenDataPipelines event to access the copies field in
your database. Also have you tried using the BeforePrint event? You could
check if the Report.PrinterDevice is not nil, and then assign the copies
property of the printer setup if necessary.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
AfterOpenDataPipelines event is raised after the PrinterSetup window is
closed, so if I put
Report.PrinterSetup.copies := 5
in this event, it only prints 1.
BeforePrint event also is raised after PrinterSetup.
Report.PrinterDevice is not nil in AfterOpenDataPipelines event, but it is
too late to change Report.PrinterSetup.Copies there because the PrinterSetup
windows is already closed.
Any other idea? Thanks,
Jose Maria Sanmartin
Sorry, I did not realize you were printing directly to the printer and
overriding the copies editbox.
Once the print dialog has closed you will need to access the print device
directly. Something like the following would work from the BeforePrint
event.
procedure TForm1.ppReport1BeforePrint(Sender: TObject);
begin
if (ppReport1.PrinterDevice <> nil) then
begin
ppReport1.PrinterDevice.Printer.PrinterSetup.Copies := 2;
end;
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Jose Maria Sanmartin