Getting around #Num!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jimmy

    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(Ca lculation),0,Ca lculation) but no dice. (The calculation/IIf
    statement is the Control Source for the control, not done through vba)


  • ruralguy via AccessMonster.com

    #2
    Re: Getting around #Num!

    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(C alculation),0,C alculation) 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.c om


    Comment

    • fredg

      #3
      Re: Getting around #Num!

      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(Ca lculation),0,Ca lculation) 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

      Comment

      • Lyle Fairfield

        #4
        Re: Getting around #Num!

        "Jimmy" <dont@email.mew rote in
        news:5G0Ah.3167 3$971.9069@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(Ca lculation),0,Ca lculation) 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.

        Comment

        Working...