Division by zero error

T

Thrava

I get a error running this one query that divides two
fields to get the percent market share.

Obviously one, or more of the denominators are zero so I
get this error message.

What is the way around this? I still like to have Access
do this division, but is there a way to have Access add
N/A for these ? or what else do people do to get around
this.

Thanks
Thrava
 
L

Lynn Trapp

You can use an IIF() statement to check for that.

IIF([YourDenominator] = 0, "N/A",[YourNumerator]/[YourDenominator])
 
R

Rick Brandt

Thrava said:
I get a error running this one query that divides two
fields to get the percent market share.

Obviously one, or more of the denominators are zero so I
get this error message.

What is the way around this? I still like to have Access
do this division, but is there a way to have Access add
N/A for these ? or what else do people do to get around
this.


=IIf([SomeField] = 0, "NA", [SomeOtherField]/[SomeField])
 
T

Thrava

Thank you very much.
This is exactly what I needed.

-----Original Message-----
You can use an IIF() statement to check for that.

IIF([YourDenominator] = 0, "N/A",[YourNumerator]/ [YourDenominator])

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


I get a error running this one query that divides two
fields to get the percent market share.

Obviously one, or more of the denominators are zero so I
get this error message.

What is the way around this? I still like to have Access
do this division, but is there a way to have Access add
N/A for these ? or what else do people do to get around
this.

Thanks
Thrava


.
 
T

Thrava

Thank you very much.
This is exactly what I needed.
-----Original Message-----
Thrava said:
I get a error running this one query that divides two
fields to get the percent market share.

Obviously one, or more of the denominators are zero so I
get this error message.

What is the way around this? I still like to have Access
do this division, but is there a way to have Access add
N/A for these ? or what else do people do to get around
this.


=IIf([SomeField] = 0, "NA", [SomeOtherField]/[SomeField])


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


.
 
L

Lynn Trapp

You are quite welcome.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Thrava said:
Thank you very much.
This is exactly what I needed.

-----Original Message-----
You can use an IIF() statement to check for that.

IIF([YourDenominator] = 0, "N/A",[YourNumerator]/ [YourDenominator])

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


I get a error running this one query that divides two
fields to get the percent market share.

Obviously one, or more of the denominators are zero so I
get this error message.

What is the way around this? I still like to have Access
do this division, but is there a way to have Access add
N/A for these ? or what else do people do to get around
this.

Thanks
Thrava


.
 

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

Top