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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help creating a Formula. I

Status
Not open for further replies.

brishanny

MIS
Oct 3, 2003
17
US
I need help creating a Formula. I am also fairly new with Crystal. I have the IF Then condition but need help with the content with-in. At this point I have no errors. I need to multiply X * Y * Z and keep getting an error saying a number is required! Please Help! Also, an error says my else statement is not part of the formula.

//Crystal Syntax
numberVar Price:=

if {vSalesmanMargins.pr_catnum} = 11 and left({vSalesmanMargins.or_codenum},1) = "L" then

numbervar X:= ((CDbl (mid({vSalesmanMargins.or_codenum}, 2,2)))/12)*2; //Price Factor

currencyVar Y:= {vSalesmanMargins.or_price}/1000; //1 board foot

numbervar Z:= cdbl(mid({vSalesmanMargins.or_codenum}, 2,2)); //Board Length

Price:= X * Y * Z

else
Price:= {vSalesmanMargins.or_price}
 
I think the problem is that you are trying to multiply number and currency variables, so I would change the currency variable to a numbervar and then format the result as a currency. Also, I think you need to add some parens as in:

numberVar Price;

if {vSalesmanMargins.pr_catnum} = 11 and left({vSalesmanMargins.or_codenum},1) = "L" then

(
numbervar X:= ((CDbl (mid({vSalesmanMargins.or_codenum}, 2,2)))/12)*2;
numbervar Y:= {vSalesmanMargins.or_price}/1000;
numbervar Z:= cdbl(mid({vSalesmanMargins.or_codenum}, 2,2));
Price:= X * Y * Z
)
else
Price:= {vSalesmanMargins.or_price}

-LB
 
X or Y (or both) don't contain what you believe them to.

Create formulas akin to:

if isnumber(
mid({vSalesmanMargins.or_codenum}, 2,2)
)
then
numbervar X:= ((CDbl (mid({vSalesmanMargins.or_codenum}, 2,2)))/12)*2; //Price Factor
else
numbervar X:=-999999

This will quickly demonstrate bad data.

You might also place alongside:
mid({vSalesmanMargins.or_codenum}, 2,2)

To see what's contained within.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top