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

Passing variable values to subreports.

edited February 2008 in General
Using RB 10.06, I am trying to pass a variable value to a subreport.
Or, in other words, I need to initialize the variable value before it
gets to the first occurence of OnCalc Event. I tried to initialize it
in the subreports' OnPrint event, but the Calc component gets resetted
between the sub's OnPrint event and it's OnCalc event.

Once I figure out how to pass a value to a subreport, I'll have to
apply it to many detail bands. I have a Master report with 3 childs.
I need a kind of running total which must be calculated and shown for
every master AND Detail band. Each Master band should pass his value
to the 1st child, which in turn will pass it to the 2nd one, and so on.

What would be the best way to acheive that?

Fred.

--

Comments

  • edited February 2008
    Hi Fred,

    Are you using RAP (Calc tab)? If so, for future reference, please either
    post your question in the RAP newsgroup or tell us you are using this
    feature before asking your question.

    For RAP, you will need to create a global variable that references the
    variable in the main report. Take a look at the following example.

    http://www.digital-metaphors.com/tips/RAPUpdateMainVariableFromChild.zip

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2008
    Nico Cizik (Digital Metaphors) wrote:


    No, I'm not. Just using some TppVariable components.


    --
  • edited February 2008
    If you are not using RAP, you should have direct access to all the report
    components from Delphi. If you need to access the value or assing the value
    of a given TppVariable, just use the variable's name...

    ppVariable1.Value := myValue;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2008
    Nico Cizik (Digital Metaphors) wrote:


    I knew that. Like I said before: I tried to initialize it
    in the subreports' OnPrint event, but the Calc component gets resetted
    between the sub's OnPrint event and it's OnCalc event.

    My concern is when should I set it's value. Which events should I use?


    --
  • edited February 2008
    Hi Fred,

    Thanks for the clarification.

    When using Variables, you need to perform all calculations/manipulation
    inside the OnCalc event. If you would like to initialize the value, you can
    do so with a separate field that always gets used in the OnCalc event.
    Something like the following..

    procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
    begin
    Value := FInitialValue + Value + 10;

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

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