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

Division by Zero Error! 1

Status
Not open for further replies.

SDS100UK

MIS
Jul 15, 2001
185
GB
Hi,

I have a formual field taht divides 1 number by another - which works quite succesfully until the second number is a zero. I know how to write it in VB but have no idea about CR.

What I want to say is
If fieldB = 0 then FormualField = 0 else fieldA/fieldB

Can anyone help? I am sure it is easy (if you know how that is!)

Many thanks


Steven
 
yep...that is the formula

numberVar FormulaField;

If fieldB = 0 then
FormualField := 0
else
FormualField := fieldA / fieldB;

FormualField;


this displays the result as well as retaians it for future use (eg. summing) if you want it

jim
 
Jim,

That sounds perfect but when I type the following first line in i get an error!
numberVar {@NewAHT};

It says that "A variable name is expected here" and goes to before my opening {

What am I doing wrong???

Thanks again

Steven
 
Hi,

It should also work just with

If {field2} = 0 then 0
else {field1} / {field2}

Geoff
 
you use NumberVar to create a numeric variable....you don't assign a formula field here....

What is {@NewAHT}???
 
{@NewAHT} is the name of my formula field.
in my Formula Field called NewAHT my full code reads:

{tblMonthlyStats1.SumOfACDTime}+{tblMonthlyStats1.SumOfACWTime})/{tblMonthlyStats1.SumOfACDCalls}

If SumOfACDCalls is Zero I need NewAht to return 0.

What is wrong??

MAny thanks

Steven
 
ok...now we have the story

just drop this code into {@NewAHT}

if {tblMonthlyStats1.SumOfACDCalls} = 0 then
0
else
{tblMonthlyStats1.SumOfACDTime}+
{tblMonthlyStats1.SumOfACWTime}/
{tblMonthlyStats1.SumOfACDCalls};

I assume you gave me the whole formula that you wanted processing...I say this because there was an extra bracket that I removed in pasting the above.

{tblMonthlyStats1.SumOfACWTime})/

is what you had listed in your last post

jim


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top