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

Newbie question

edited October 2004 in General
Hello,

I have a (hopefully) very simple question with RB7 Standard for D6. I am
printing reports through my app using File Templates. I am using the
logic below:

ppReport.Template.FileName := 'c:\MyReport.rtm';
ppReport.Template.LoadFromFile;
ppReport.Print;

but I have it implemented as:

OnBeforePrintEvent:
ppReport.Template.FileName := 'c:\MyReport.rtm';
ppReport.Template.LoadFromFile;

My main printing routine:
ppReport.Print;

In my BeforePrint event, I specify one of several templates to use, based
upon prior user selections.

My problem:
The user can select and print any report the first time with no problems.
However, when they try to select a second report and print, the FIRST
report is reprinted! I tried debugging with showmessages in the
BeforePrint event to verify the template being used and found that the
BeforePrint event is only called before the FIRST REPORT!

Is there some command I need to issue to flush things out so the
BeforePrint will fire again?

Thanks,

Rich Ackerson

Comments

  • edited October 2004

    Report.BeforePrint occurs too late. Use the first implemenation that you
    show - that will work....

    ppReport.Template.FileName := 'c:\MyReport.rtm';
    ppReport.Template.LoadFromFile;
    ppReport.Print;


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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2004
    "Nard Moseley \(Digital Metaphors\)"
  • edited October 2004

    BeforePrint occurs after the report engine has been initialized. It fires
    prior to any report pages being generated. And it fires each time the report
    is asked to generate pages to a different output device. For example it
    fires to generate to preview and it fires again to generate to printer. So
    you could use it to determine whether a report is being generated to a
    printer or screen.

    It can be used to control a great many things, but it occurs after the
    report engine has analyzed the report layout and opened datapipelines, etc.
    You can modify the report layout, set object visibility, but you should load
    an entire report layout.


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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2004
    > It can be used to control a great many things, but it occurs after the

    Ah, I see. Thank you very much for clearing that up for me.

    Regards,

    Rich
This discussion has been closed.