VBA 0 divided by 0 = Overflow

bchaikin

New member
Local time
Today, 08:34
Joined
Mar 28, 2013
Messages
2
I have what I thought was a simple piece of code that divided the total cost / the units. However, if both values = 0, I get an overflow message

theValue = (rs!Charge_Total - rs!Charge_Shipping) / rs!Charge_Subtotal

All three values in the table = 0
 
Welcome to the forum.

If you try and divide any number by Zero you are going to get an error.
 
Ok? The first day of division they teach you that you cannot divide by 0.

What would you like to occur when rs!Charge_Subtotal is 0? To do that you must create a conditional statement (IIf), test to see if that value is 0, spit out what you want to spit out when it is 0 and do the calculaton if it is not.
 
Thanks guys. My teacher should have taught me that.

The if statement resolved it.
 

Users who are viewing this thread

Back
Top Bottom