DataColum.Expression (IIF Function Bug)

  • Thread starter Thread starter Paul Say
  • Start date Start date
P

Paul Say

I am trying to prevent the following error
System.DivideByZeroException: Attempted to divide by zero.

When populating a calculated field. I tried using the IIF() function,
however this was no help as the function attempts to calculate both the true
and false return values before doing the IF test (A bug with this function I
believe)

objColumn.Expression =
"IIF([Original_Contract_Amount]>0,([Original_Contract_Amount] -
[Original_Estimate])/([Original_Contract_Amount]),0)"

Just wondering if anyone any sugesstions for a work arround.


Thanks Paul
 
the problem is no "shortcut logic". I guess the solution could be like:
IIF([OCA]>0,([OCA] - OE])/(IIF([OCA]>0,OCA,1)),0)
 
Thankyou

I came up with the same solution, and it works fine.


Uri Dor said:
the problem is no "shortcut logic". I guess the solution could be like:
IIF([OCA]>0,([OCA] - OE])/(IIF([OCA]>0,OCA,1)),0)

Paul said:
I am trying to prevent the following error
System.DivideByZeroException: Attempted to divide by zero.

When populating a calculated field. I tried using the IIF() function,
however this was no help as the function attempts to calculate both the true
and false return values before doing the IF test (A bug with this function I
believe)

objColumn.Expression =
"IIF([Original_Contract_Amount]>0,([Original_Contract_Amount] -
[Original_Estimate])/([Original_Contract_Amount]),0)"

Just wondering if anyone any sugesstions for a work arround.


Thanks Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access My Expression Contains Wrong number of arguments 0
Access Ms Access 0
IIF function 9
Access Query problem 1
Limits of IIF? 4
Validate the number of checkboxes that can be true 0
Limits of IIF? 1
Writing Multiple IIF Function 3

Back
Top