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

Division by 0 Error 1

Status
Not open for further replies.

Randygk

Technical User
Jun 10, 2003
26
US
I am trying to create a formula whereby I divide one field by another. In some cases the field used as the denominator must be a 0, because I get a &quot;division by 0&quot; error. I want to create a statement that would state (If standard_cost <> 0 then price_8/standard_cost else ??????). Can you give me the correct syntax or some sort of direction how I can weed out the division by 0.

Thanks in Advance,
Randy
 
You pretty much nailed it:

If standard_cost <> 0 then
price_8/standard_cost
else
0

-k
 
When I enter that formula I receive the error &quot;A number, Currency amount, Boolean, Date-Time, or string is expected here.
 
Randy,

Please post your entire formula, via cut and paste method, to this thread. Also show where in the formula the cursor is when you are getting this error.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
If standard_cost <> 0 then
price8/standard_cost
else
0
 
hi
is your field a number, string???
if
tonumber({standard_cost}) <> 0
then
price_8/tonumber({standard_cost})
else
0



cheers

pgtek
 
Randy,

I am assumming that standard_cost is a database field. If so the you must have it bracketed per the following example:

{standard_cost}

This happens automatically when you select the field from the formula editor tree. I suspect you are just keying in the formula. Try the following:

If {standard_cost} <> 0 then {price8}/{standard_cost} else
0





Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
The error is self describing, you're attempting to do math using the wrong data type.

Right click each field and select browse, Crystal will demonstrate it's data type. If it's not a numeric, use the VAL() function againjst it in the formula.

-k

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top