473,395 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Overflow Error

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
5 2801
"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
Ok I get a loser of the day award!

Thanks........

-Brian

Nov 13 '05 #3
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike | last post by:
I am trying to use the bulk insert command but I am getting the following error: ---Begin Error Msg--- Server: Msg 4867, Level 16, State 1, Line 1 Bulk insert data conversion error (overflow)...
2
by: Robert McEuen | last post by:
Using Access 97, Windows XP I'm receiving a Numeric Field Overflow error during text import that I did not receive before I split my database. Another thread I found suggested that the cause of...
7
by: MLH | last post by:
?2944*24 gives me an overflow error, entered in the immediate window. Anybody else?
4
by: Chua Wen Ching | last post by:
Thanks Derek... Okay i had another question.. my program runs smoothly for the first minute, after 1 minute... suddenly it breaks and display this error: do you know what is the cause of...
4
by: vir | last post by:
we use an E-office application where server is SQL server 7.0 and client side its MS access In our VB program we use ASP to synchronization and update client database from server and each table...
3
by: capes | last post by:
Hi, I have a structure called Tissue and I use it in a matrix like this: vector < vector < Tissue* tissueArray(cRows); This whole function works great for a matrix size of 2X2 to 15X15....
1
by: zaneh | last post by:
I have found TheScripts a very useful site, but however I cannot find an answer to a problem I am having, so I finally have to ask the question! I am getting an Overflow error in a Function I have...
3
by: MLH | last post by:
A wide comma delimited text file import into A97 failed with an overflow error. I'm estimating it to have been no more than 1000 records. 100% of all the fields were quoted strings or ZLS's. ...
3
by: Tophurious | last post by:
Ok, I've been working on this for two days and have finally resulted to asking for help. I am designing a program for my work that will emulate the thermodynamic systems of a power plant. however, I...
3
by: jer006 | last post by:
Hi I am writing a select statement that has an arithmetic function inside a case statement that uses logic to decide whether to divide or multiply and when I run the arithmetic statements outside...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.