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

Update data after finish printing

edited December 2003 in General
I'm currently using RB7.03 Ent on Delphi7

//I have the following code which i had assigned to a button on click event
rptFCPCoupon.Template.FileName := strReportPath + 'rptFCPCoupon.rtm';
rptFCPCoupon.Template.LoadFromFile;
rptFCPCoupon.DeviceType := 'Print';
rptFCPCoupon.Print;

rptFCPCoupon -> TppReport

i would like to update a field called [PrintedDate] in a table this code
should get executed if the user presses the print button on the preview
form. I had tried to code on the AfterPrint of Tppreport event but it's not
working

Comments

  • edited December 2003
    Hello,

    Is the code you have in the Report.AfterPrint event being executed? Place a
    stop inside this event to be sure. The AfterPrint event will fire after
    printing to the printer is complete as well as after the printpreview is
    closed, so be aware of that. Nevertheless, if the code in the AfterPrint
    event is in fact being executed, this is where the problem lies. Perhaps a
    look at this code could provide some clues to what is happening.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2003
    i tried just by putting ina showmessage but it never get executed.
    fyi all the codes i had wrote in Delphi source code not in rtm file

  • edited December 2003
    Hi,

    As a test, try disconnecting all your event handlers except for the
    AfterPrint method and be see if it fires then. If it does, try
    incrementally adding them back to isolate the problem. If not, please send
    a small example demonstrating the problem in .zip format to
    support@digital-metaphors.com and I'll take a look at it for you.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2003
    Hello,

    Check out the following article for a possible solution.

    --------------------------------------------
    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
This discussion has been closed.