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

OnPrint being called twice.

edited July 2004 in General
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.

Thanks,

Shane

Comments

  • edited July 2004
    Hi Shane,

    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.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Hi Nico,

    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


  • edited July 2004
    most likely in the before print
    or before you even issue report.print...


  • edited July 2004
    Hi Shane,

    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.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    OK Nico and Marc thanks.

    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


  • edited July 2004
    Hi 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.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.