I have two TppLine objects on a form (among many other objects), that have their OnPrint event firing twice. Can anyone tell me why this would be. All the relevant properties are the same as the other TppLine objects.
The only event in ReportBuilder that is guarenteed only to fire once per traversal is the TppVariable.OnCalc event. All other events can be fired more than once per traversal or generation depending on the specifics of your report design. If you need to make calculations in a report, it is best to use the TppVariable.OnCalc event or add some sort of check in the other event code to ensure it has only been executed once.
Yes, Marc is correct. If you are moving components around inside a report the best place to do so is before calling Report.Print. The Report.BeforePrint event may work as well although you must remember that if you preview your report first then print it to the printer, this event will fire more than once.
My question still remains. If I need to move objects on the report to account for changes in the non-printable areas in different printers, how can I do this before the report.print is called when I don't know what printer the user will be directing the output to. If I have to do it after report.print then I guess I need to manage the fact that this is being called more than once. Seems clumsy, unless I am missing something...
My suggestion would be to still use the Report.BeforePrint event but set a global flag inside this event so that if the event fires more than once, you can prevent the code from executing over again.
Comments
The only event in ReportBuilder that is guarenteed only to fire once per
traversal is the TppVariable.OnCalc event. All other events can be fired
more than once per traversal or generation depending on the specifics of
your report design. If you need to make calculations in a report, it is
best to use the TppVariable.OnCalc event or add some sort of check in the
other event code to ensure it has only been executed once.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
So if I am moving Objects around the report (lines, labels, etc.), I
shouldn't do it in the OnPrint event? If not, when? report.BeforePrint?
Shane
or before you even issue report.print...
Yes, Marc is correct. If you are moving components around inside a report
the best place to do so is before calling Report.Print. The
Report.BeforePrint event may work as well although you must remember that if
you preview your report first then print it to the printer, this event will
fire more than once.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
My question still remains. If I need to move objects on the report to
account for changes in the non-printable areas in different printers, how
can I do this before the report.print is called when I don't know what
printer the user will be directing the output to. If I have to do it after
report.print then I guess I need to manage the fact that this is being
called more than once. Seems clumsy, unless I am missing something...
Shane
My suggestion would be to still use the Report.BeforePrint event but set a
global flag inside this event so that if the event fires more than once, you
can prevent the code from executing over again.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com