Overflow Error

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

    #1

    Overflow Error

    I am getting an overflow error on the following:

    intPercentNotPa id = IIf(intNumberAp proved = 0, 0, intNumberNotPai d /
    intNumberApprov ed)

    The intNumberapprov ed is 0, but it is still evaluating the False part
    of the IIf and thus throwing me into the error. It should just be
    setting intPercentNotPa id = 0

    Should I just do an if statement and skip the calculation if
    intNumberApprov ed = 0 ?

    Thanks,
    Brian

  • Randy Harris

    #2
    Re: Overflow Error

    "BerkshireG uy" <bdaoust@yahoo. com> wrote in message
    news:1114785163 .974767.262570@ o13g2000cwo.goo glegroups.com.. .[color=blue]
    > I am getting an overflow error on the following:
    >
    > intPercentNotPa id = IIf(intNumberAp proved = 0, 0, intNumberNotPai d /
    > intNumberApprov ed)
    >
    > The intNumberapprov ed is 0, but it is still evaluating the False part
    > of the IIf and thus throwing me into the error. It should just be
    > setting intPercentNotPa id = 0
    >
    > Should I just do an if statement and skip the calculation if
    > intNumberApprov ed = 0 ?
    >
    > Thanks,
    > Brian
    >[/color]

    This is from the A2K docs:
    Remarks

    IIf always evaluates both truepart and falsepart, even though it returns
    only one of them. Because of this, you should watch for undesirable side
    effects. For example, if evaluating falsepart results in a division by zero
    error, an error occurs even if expr is True.


    Comment

    • BerkshireGuy

      #3
      Re: Overflow Error

      Ok I get a loser of the day award!

      Thanks........

      -Brian

      Comment

      • Randy Harris

        #4
        Re: Overflow Error

        "BerkshireG uy" <bdaoust@yahoo. com> wrote in message
        news:1114785970 .115570.80470@g 14g2000cwa.goog legroups.com...[color=blue]
        > Ok I get a loser of the day award!
        >
        > Thanks........
        >
        > -Brian[/color]

        Nah - no loser award. When I saw your post I remembered having read this in
        the docs. The reason I remembered it, is that it seemed so "wrong". Why
        evaluate all of the arguments? It struck me as being very innefficient.
        That behavior is not what I would call "intuitive" .

        Randy


        Comment

        • lesperancer@natpro.com

          #5
          Re: Overflow Error

          interesting, so converting from access97 to access2k could require a
          mass conversion to fix this syntax

          Randy Harris wrote:[color=blue]
          > "BerkshireG uy" <bdaoust@yahoo. com> wrote in message
          > news:1114785970 .115570.80470@g 14g2000cwa.goog legroups.com...[color=green]
          > > Ok I get a loser of the day award!
          > >
          > > Thanks........
          > >
          > > -Brian[/color]
          >
          > Nah - no loser award. When I saw your post I remembered having read[/color]
          this in[color=blue]
          > the docs. The reason I remembered it, is that it seemed so "wrong".[/color]
          Why[color=blue]
          > evaluate all of the arguments? It struck me as being very[/color]
          innefficient.[color=blue]
          > That behavior is not what I would call "intuitive" .
          >
          > Randy[/color]

          Comment

          • Rick Brandt

            #6
            Re: Overflow Error

            lesperancer@nat pro.com wrote:[color=blue]
            > interesting, so converting from access97 to access2k could require a
            > mass conversion to fix this syntax[/color]

            Access 97 behaves the same way. This is from the Access 97 help file...

            *************** ************
            Remarks
            IIf always evaluates both truepart and falsepart, even though it returns
            only one of them. Because of this, you should watch for undesirable side
            effects. For example, if evaluating falsepart results in a division by zero
            error, an error occurs even if expr is True.
            *************** ************

            What you might have seen is that this behavior is not true in any version
            when IIf() is used in a query. It is only when used in VBA code that both
            parts are evaluated.

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


            Comment

            Working...