Report Calc events
We have a report where in the designer we've added some code to the OnBeforePrint event to setup the Report.PrinterSetup.PrinterName and this seems to work when we open the report in the reportbuilder. In the preview we can see that it hits some code that we've made within the OnBeforePrint event.
But if we load this report in Delphi itself via the TppReport object, this event doesn't get triggered. I've read here: https://digital-metaphors.com/forums/discussion/14374/report-explorer-and-tppreport-afterprint that this might have to do with loading in a template.
But it is unclear to me how I can then fix this. The source of the articles, that are described in that topic, are not linked so I cannot explore further of my options. We want to load the report in code and then print it, but the beforePrint event has to be triggered in order to setup the PrinterName correctly.
But if we load this report in Delphi itself via the TppReport object, this event doesn't get triggered. I've read here: https://digital-metaphors.com/forums/discussion/14374/report-explorer-and-tppreport-afterprint that this might have to do with loading in a template.
But it is unclear to me how I can then fix this. The source of the articles, that are described in that topic, are not linked so I cannot explore further of my options. We want to load the report in code and then print it, but the beforePrint event has to be triggered in order to setup the PrinterName correctly.
Comments
https://rbwiki.digital-metaphors.com/design/templates/how-to-troubleshoot-lost-event-handlers/
Generally, when a template is loaded, all Delphi event references are lost and need to be re-connected after loading has occurred.
The best way to overcome this is to keep all event code local to the report template itself by using RAP (code tab of the report designer). This way the event code is never lost when the template is loaded and it can be customized for individual reports easily.
According to our database, you already have the Enterprise edition of ReportBuilder so RAP is available to you. I suggest spending some time working through some of the RAP demos to see if it is right solution.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com