Home General

Using If commands etc

edited July 2001 in General
Hi, I am a beginner to report writing and wonder if you could help me with a
problem I have come up against.

I have a DBtext18 field on a form which is a new field I have created which
calculates the discount in an invoice i.e.
((Retail*Qty)-Total_Goods)/(Retail*Qty)*100. If this value is zero I need
the words 'Nett' to printout otherwise the value (of the DBtext18 field).
Can you help, I presume it is achieved with an If/Else command. I've tried
a few things but failed.

Regards

Comments

  • edited July 2001
    Use a string type TppVariable and code its OnCalc event handler. The OnCalc
    will fire exactly as it is configured in the timing dialog(right-mouse-click
    over the variable). It should be set to calculate on traversal. Be sure to
    set the variable's type in the drop down list box in the designer (left side
    of tool bars). In the OnCalc, you can access the field value from the
    pipeline directly. Then set the variable's string value to 'Nett' when
    zero, or set it to the pipeline field value as a string.

    In the Variable.OnCalc
    var
    ldMyValue: Double;
    begin

    ldMyValue := plCustomerOrders['Amount_Paid'];

    if ldMyValue = 0 then
    Value := 'Nett'
    else
    Value := '$' + FloatToStr(ldMyValue);


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.