471,319 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Getting around #Num!

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
3 29047
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
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
"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.

Similar topics

7 posts views Thread by Jane Austine | last post: by
1 post views Thread by Vernon | last post: by

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.