By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,778 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,778 IT Pros & Developers. It's quick & easy.

Overflow Error

P: n/a
I am getting an overflow error on the following:

intPercentNotPaid = IIf(intNumberApproved = 0, 0, intNumberNotPaid /
intNumberApproved)

The intNumberapproved is 0, but it is still evaluating the False part
of the IIf and thus throwing me into the error. It should just be
setting intPercentNotPaid = 0

Should I just do an if statement and skip the calculation if
intNumberApproved = 0 ?

Thanks,
Brian

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"BerkshireGuy" <bd*****@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I am getting an overflow error on the following:

intPercentNotPaid = IIf(intNumberApproved = 0, 0, intNumberNotPaid /
intNumberApproved)

The intNumberapproved is 0, but it is still evaluating the False part
of the IIf and thus throwing me into the error. It should just be
setting intPercentNotPaid = 0

Should I just do an if statement and skip the calculation if
intNumberApproved = 0 ?

Thanks,
Brian


This is from the A2K docs:
Remarks

IIf always evaluates both truepart and falsepart, even though it returns
only one of them. Because of this, you should watch for undesirable side
effects. For example, if evaluating falsepart results in a division by zero
error, an error occurs even if expr is True.
Nov 13 '05 #2

P: n/a
Ok I get a loser of the day award!

Thanks........

-Brian

Nov 13 '05 #3

P: n/a
"BerkshireGuy" <bd*****@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Ok I get a loser of the day award!

Thanks........

-Brian


Nah - no loser award. When I saw your post I remembered having read this in
the docs. The reason I remembered it, is that it seemed so "wrong". Why
evaluate all of the arguments? It struck me as being very innefficient.
That behavior is not what I would call "intuitive".

Randy
Nov 13 '05 #4

P: n/a
interesting, so converting from access97 to access2k could require a
mass conversion to fix this syntax

Randy Harris wrote:
"BerkshireGuy" <bd*****@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Ok I get a loser of the day award!

Thanks........

-Brian
Nah - no loser award. When I saw your post I remembered having read

this in the docs. The reason I remembered it, is that it seemed so "wrong". Why evaluate all of the arguments? It struck me as being very innefficient. That behavior is not what I would call "intuitive".

Randy


Nov 13 '05 #5

P: n/a
le*********@natpro.com wrote:
interesting, so converting from access97 to access2k could require a
mass conversion to fix this syntax


Access 97 behaves the same way. This is from the Access 97 help file...

***************************
Remarks
IIf always evaluates both truepart and falsepart, even though it returns
only one of them. Because of this, you should watch for undesirable side
effects. For example, if evaluating falsepart results in a division by zero
error, an error occurs even if expr is True.
***************************

What you might have seen is that this behavior is not true in any version
when IIf() is used in a query. It is only when used in VBA code that both
parts are evaluated.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.