Access VBA error "Overflow"

daryll

Registered User.
Local time
Today, 14:07
Joined
Jan 2, 2018
Messages
49
Hi!

Why this code still throws an overflow error
Code:
IIf( (cbStatNotStarted=0 Or cbStatTotal=0), 0, (cbStatNotStarted / cbStatTotal) * 100 )
 
I suspect it has something to do with the numbers themselves. Can you provide an example of what kind of values are in the equation.

Also, you should always check for null and Zero values, especially if you are doing division.
 
Apologies, forget about what I said regarding checking for Zero, I can see now that you have.

I tend to go off half-cocked...
 
Let me guess, your solution was
Code:
IIf( (nz(cbStatNotStarted,0)=0 Or nz(cbStatTotal,0)=0), 0, (cbStatNotStarted / cbStatTotal) * 100 )

so you could check for either zero OR null all in one fell swoop?
 
Let me guess, your solution was
Code:
IIf( (nz(cbStatNotStarted,0)=0 Or nz(cbStatTotal,0)=0), 0, (cbStatNotStarted / cbStatTotal) * 100 )

so you could check for either zero OR null all in one fell swoop?

This is the version I have

Code:
(IIf(cbStatNotStarted = 0, 0, cbStatNotStarted) / IIf(cbStatTotal = 0, 1, cbStatTotal)) * 100
 
No need to test cbSTartNotStarted at all:


For all x<>0, 0/x = 0
 

Users who are viewing this thread

Back
Top Bottom