cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report formula error *

arunsapbone
Discoverer
0 Kudos

Dear Experts,

I am getting the error in my crystal report formula, mentioned in my formula below.

I have to exclude the and zero from my crystal result.

Formula : numbervar x := {@TotalInvoiceAmount}; numbervar ipart; numberVar decpart; ipart := int(x); decpart := x - ipart; Propercase(Replace(towords(ipart)," and xx / 100",""))& " only" & if decpart = 0 then "" else " and "& Propercase(Replace(towords(decpart)," and xx / 100","")) &" only ";

Result: Ten Thousand Five Hundred One and Zero And 69 / 100 only

former_member759204
Participant
0 Kudos

Try this:

numbervar x := {OEINVH.INVNETWTX};

numbervar ipart:= int(x);

numberVar decpart:= x - ipart;

If decpart <> 0 then Propercase(towords({OEINVH.INVNETWTX})) + " only" else Propercase(towords({OEINVH.INVNETWTX},0)) + " only"

Accepted Solutions (1)

Accepted Solutions (1)

arunsapbone
Discoverer
0 Kudos

Thanks, Jody

It's working fine.

arunsapbone
Discoverer
0 Kudos

numbervar x := {OEINVH.INVNETWTX};

numbervar ipart:= int(x);

numberVar decpart:= x - ipart;

If decpart <> 0 then Propercase(towords({OEINVH.INVNETWTX})) + " only" else Propercase(towords({OEINVH.INVNETWTX},0)) + " only"

Answers (1)

Answers (1)

DellSC
Active Contributor
0 Kudos

You can't use an If statement in the middle of building a string. I suggest creating a new string variable that will handle the "if" part of your logic. It will look something like this:

 numbervar x := {@TotalInvoiceAmount}; 
 numbervar ipart; 
 numberVar decpart; 
 stringvar endwords = " only";
 ipart := int(x); 
 decpart := x - ipart;
 if decpart <> 0 then and := " and " & Propercase(Replace(towords(decpart)," and xx / 100","")) & 
	 " only ";
 Propercase(Replace(towords(ipart)," and xx / 100",""))& endwords;

-Dell