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

Getting around #Num!

P: n/a
One of the calculated controls on my form often divides by 0 thus giving the
#Num! error in the control. Is there a way I can write my calculation to
avoid this, i.e. display 0 if this occurs? I tried using
=IIf(IsError(Calculation),0,Calculation) but no dice. (The calculation/IIf
statement is the Control Source for the control, not done through vba)
Feb 12 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
How about:
IIF( Nz(Divisor,0)=0,0,Calculation)

Jimmy wrote:
>One of the calculated controls on my form often divides by 0 thus giving the
#Num! error in the control. Is there a way I can write my calculation to
avoid this, i.e. display 0 if this occurs? I tried using
=IIf(IsError(Calculation),0,Calculation) but no dice. (The calculation/IIf
statement is the Control Source for the control, not done through vba)
--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200702/1

Feb 12 '07 #2

P: n/a
On Mon, 12 Feb 2007 16:34:09 GMT, Jimmy wrote:
One of the calculated controls on my form often divides by 0 thus giving the
#Num! error in the control. Is there a way I can write my calculation to
avoid this, i.e. display 0 if this occurs? I tried using
=IIf(IsError(Calculation),0,Calculation) but no dice. (The calculation/IIf
statement is the Control Source for the control, not done through vba)
Test if the divisor's value is 0 first:
=IIf([SomeField]=0,0,[AField]/[SomeField])
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Feb 12 '07 #3

P: n/a
"Jimmy" <do**@email.mewrote in
news:5G******************@fe01.news.easynews.com:
One of the calculated controls on my form often divides by 0 thus
giving the #Num! error in the control. Is there a way I can write my
calculation to avoid this, i.e. display 0 if this occurs? I tried
using =IIf(IsError(Calculation),0,Calculation) but no dice. (The
calculation/IIf statement is the Control Source for the control, not
done through vba)
If a division by zero error happens then you have an error in logic or
design; the error #num is raised to alert you to this.

To avoid the error with a conditional statement is, in my opinion,
enormously bad form, and if not handled carefully could result in
catastrophic results. If a conditional statement gaurding against division
by zero had any validity at all, it's unlikely that you would have to
script it yourself, division would just work that way.

Cure the error; don't plaster over it.
Feb 12 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.