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

Report was printed

edited December 2003 in General
Hi,

Is there a way of finding out if the report had been printed if the user
selected to preview it first?

Regards
NB

Comments

  • edited December 2003
    Hello,

    I'm assuming you are using the Report Explorer and want to find out if your
    users have selected to print or preview directly from there. Since you are
    dynamically loading templates when you use the Explorer you will have two
    options.

    1. Use the Template OnLoadEnd event to assign certain events (ie.
    OnPreviewFormCreate, OnBeforePrint) to the report, then using those events,
    you should be able to check the device type that is being used to print and
    find out if the user has selected to print or preview. See the article
    below on how to use template events.

    2. Create a custom Report Explorer and taylor it to your needs. An example
    of creating a custom Explorer is available in the Developer's Guide.

    ----------------------------------------------
    Tech Tip: Using Template Events
    ----------------------------------------------

    The Report.Template object has several events that can be used for
    customizing what happens when a report is loaded or saved:

    - OnLoadStart
    - OnLoadEnd
    - OnNew
    - OnSaveStart
    - OnSaveEnd


    The OnLoadEnd and OnNew events are often used to perform actions related
    to report and data initialization.

    The OnSaveEnd event is often used to save additional descriptive
    ("meta") data to the database each time the report is saved.

    Example:

    The Report.Template events are public and therefore must be assigned at
    run-time.


    1. In the private section of your form declaration you can declare an
    event-handler method:

    TForm = class(TForm)
    private
    procedure myTemplateOnLoadEndEvent(Sender: TObject);

    public

    end;


    2. In the Form.OnCreate event, you can assign the event-handler to the
    event:

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;

    end;


    3. Implement the event-handler method:

    procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
    begin

    {add code here to initial the report or data, etc. }
    ppReport1.PrinterSetup.MarginTop := 0.5;

    end;


    --
    Best Regards,

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