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

Using a variable in another calculation

edited May 2004 in General
Is here a way to use a variable in an calculation in another variables
caculation?

procedure TrptSalesNew.ppVariable2Calc(Sender: TObject;
var Value: Variant);
begin
value := tblReportW.fieldbyname('grossdue').asFloat -
tblReportW.fieldbyname('commission').asFloat;
end;

procedure TrptSalesNew.ppVariable3Calc(Sender: TObject;
var Value: Variant);
begin
value := ppVariable2.asFloat / tblReportW.fieldybname('seats').asInteger;
end;

Comments

  • edited May 2004
    Hi Rob,

    Yes, this type of calculation should be possible in ReportBuilder. Remember
    that if these two variables are in the same band, you will need to adjust
    the z-order of the variables (send to back, bring to front) to ensure that
    ppVariable2 is calculated before ppVariable3.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2004
    Is there something a little more specific on determining the order the
    calculations are done? I have serveral ppDBCalcs in a band that I want to
    use in ppvariable calculation. If the calculatiions are dependent on the
    z-order, then someone could come in during design time and unknowingly
    bring an object to the front or send it to the back, thereby changing the
    calculation.


  • edited May 2004
    Hi Rob,

    Sorry, the z-order is the only way ReportBuilder knows which drawcommands to
    render to a page at a given time. You will either need to inform your users
    of this requirement, or perhaps create a utility that loops through each
    drawcommand and ensures each of your variables are in the correct order.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2004
    Hi Rob,

    Sorry, I must be loosing it today :). The DBCalc components are meant to be
    stand alone objects. If you would like to make calculations on data in your
    report, I would recommend just using TppVariables. This way you can adjust
    the Calc Order of these variables and your users will not be able to change
    this even if they move the variables around. To access the Calc Order,
    simply right click over some empty space in the current band and select the
    Calc Order option from the popup menu.

    --
    Best Regards,

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