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

Access variable in saved report

edited February 2004 in General
Hi,

I create a report with Variable1 (type Boolean)
I saved this report and I load it dynamically.
What's the way to modify the value of Variable1 before preview or printing ?

Regards,

J-Luc !

Comments

  • edited February 2004
    Hi,

    I would suggest using one of the template events to do this. The OnLoadEnd
    event should do the trick.

    ----------------------------------------------
    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
  • edited February 2004
    Nico Cizik (Digital Metaphors) a présenté l'énoncé suivant :


    Yes that's that I use !
    I have found an example in your tech tips news.
    To access a component, I use a loop and I test on component name

    But my question is: Is it possible to access TppVariable and modify the
    value before printing ?
    I have tried with Parameters list but It seem that I can't change value
    of one variable ...

    --
    J-L M. (Alphomega)
    Perso: http://alphomega.free.fr
    Boulot: http://Ecilia.fr
    Dodo: http://DansMonlit.fr
  • edited February 2004
    Hi,

    Sorry about that, I misunderstood the question. Parameters are probably the
    best way to go with this. The reason the TppVariable's value is not showing
    up is because ReportBuilder initialized all variable values before the
    report prints. When using parameters, you will need to update the
    TppVariable's value inside the OnCalc event to change it successfully.


    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2004
    Nico Cizik (Digital Metaphors) a formulé la demande :

    :-)



    Thanks a lot !

    --
    J-L M. (Alphomega)
    Perso: http://alphomega.free.fr
    Boulot: http://Ecilia.fr
    Dodo: http://DansMonlit.fr
This discussion has been closed.