Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unable to add formula field as it displays error 1

Status
Not open for further replies.

clara1

Programmer
Sep 6, 2021
2
IN
Hello all,

I am trying to add new formula field (let say result) in crystal report.

The value for result field is calculated based on fields already exist in database.

The fields which I use for calculation (lets say y and z) are declared as "nvarchar" datatype in sql. (fields may contain string/number/decimal value for different rows)

I need to calculate and show result value in report only if Y field is not null and Y,Z field contains numeric or decimal value. Else,then it not need to display anything in result field..simply it can show as blank in report.

Anyone help me to declare the condition. I tried it as below.

If ({tablename.Y} <> isnull) -->receiving error
then
NumberVar result; -->declaring variable to store the value
result:={tablename.y}+(8*({tablename.z}-{tablename.y}))
Else
{
}





 
please help me if anyone knows any solution for above request..
 
Hi clara1

I'm not absolutely clear I understand, but something like the following should work I think:

Code:
WhilePrintingRecords;
Global NumberVar result;

If      Not Isnull({tablename.Y})
Then    If      IsNumeric({tablename.X}) and
                IsNumeric({tablename.Y})
        Then    result := Val({tablename.Y}) + 8*(Val({tablename.X}) - {tablename.z})
        Else    result := 0
Else    result := 0;

result

Hope this helps.

Cheers
Pete
 
The isNull function in Crystal requires an argument (usually a field)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top