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

Capturing output afer preview

edited April 2004 in General
I have a bunch of reports that log information in the database when being
generated. The logging only occurs if the report is going to the printer
upon ppDetailBandBeforePrint.

My problem is that if I preview the report first, and it is a short report,
the Before Print is never fired, therefore the information does not get
logged. Is there a way that when they go to print, I can force the report
to begin afresh (or is there another solution?)

Note that none of the events (BeforeGenerate, AfterGenerate, BeforePrint,
AfterPrint) get fired if I preview first.

Thanks

Comments

  • edited April 2004
    Hi Joseph,

    The Report.BeforePrint should fire when printing to the printer. Are you
    loading these reports as templates? If so you may be loosing your event
    handlers. See the article below on lost event handlers. Also, you may want
    to check out Demo 144 (dm0144.pas) located in the \RBuilder\Demos\1.
    Reports\... directory. This uses our Event Tracker form to log each event
    that is fired during report generation. You can use this to see exactly
    which events are fired and when. (This is what I used to be sure the
    BeforePrint event fired after you print from the preview.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2004
    Sorry, forgot the article...

    --------------------------------------------
    Article: Troubleshooting Lost Event Handlers
    --------------------------------------------

    Let's assume you have created a report in Delphi and assign an event
    handlers to the OnPreviewFormCreate event of the report. The event is
    generated by Delphi as:

    procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);

    You then save the report to an RTM file 'Report1.RTM.' The events are
    stored as references only, and so the RTM contains:

    object ppReport1: TppReport
    .
    .
    OnPreviewFormCreate = ppReport1PreviewFormCreate
    end

    You then go on to work on a different report. Saving it with under then
    name 'Report2.RTM'. Only this time, before you save the report you
    change the report component name to: rptOrders. Delphi automatically
    updates the event declaration for OnPreviewFormCreate event to:

    procedure TForm1.rptOrdersPreviewFormCreate(Sender: TObject);


    You then create two buttons on the form, one to load Report1 and
    preview, the other to load Report2 and preview. When you run the app
    and click Report1, you an error. This is because the Report1.RTM file
    contains a reference to ppReport1PreviewFormCreate, a method which no
    longer exists (at least with this name) in the form.

    One answer is to load all your rtm files into the report component you
    will be using for loading. Fix any errors, reassign any events that get
    cleared. This will update your rtms to contain the proper event handler
    names.


    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2004
    The Report.OnPrint does fire as I expect. The problem is the DetailBand.On
    print, which does not seen to get fired. (and it is not a template)

    Thanks

    Joe


  • edited April 2004
    Hi Joe,

    Unfortuntately I do not believe there is an easy way to accomplish. The
    AutoSearch feature calls the TppViewer.RegenerateReport method to run the
    report over again and refresh the data... you may be able to use this method
    somehow. Otherwise, you could always wait until the report has finished
    printing and then traverse the datapipeline again updating your data for
    each record.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2004
    Actually, what I ended up doing is to add
    ppReport.DataPipeline.First;
    ppReport.ResetDevices;

    To the OnPrintDialogClose. It seems to work fine.

    Thanks


This discussion has been closed.