"Overflow" error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SheldonMopes@KidNet.com

    "Overflow" error

    I sometimes get a pop-up box that reads "Overflow" and the module that
    is executing pauses. It doesn't get caught by my error trapping, and
    it seems to be randow. By random, I mean usually in the same section
    of code, but I can run the code a few times, then it appears. I can't
    reproduce it when I want to, and I have no idea what is causing it.
    Any ideas ? Thanks
    By the way the code is some record manipulation of 2 recordsets.

  • Allen Browne

    #2
    Re: "Overflow& quot; error

    Overflow means that the data is too large for the data type that is trying
    to handle it.

    Open the Immediate Window (Ctrl+G), and enter:
    ? 200 * 200
    The default number type in Access is Integer, and the largest integer is
    32767. Therefore this simple calculation fails with an Overflow error. The
    solution is to force one of the numbers to be a Long integer, e.g.:
    ? CLng(200) * 200

    Your calculations may therefore need typecasting to a Long, Double, or
    Currency, using CLng(), CDbl(), or CCur(). Note that these types do not
    handle Null, so you usually need to use Nz() inside those expressions too,
    e.g.:
    CCur(Nz([Quantity],0)) * [PriceEach]

    More info:
    Calculated fields misinterpreted
    at:
    Explains how Microsoft Access can misunderstand the intended data type of calculated fields and unbound controls, and explains how to avoid these issues.


    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    <SheldonMopes@K idNet.com> wrote in message
    news:4420b3ce.2 18328@news-server...[color=blue]
    >I sometimes get a pop-up box that reads "Overflow" and the module that
    > is executing pauses. It doesn't get caught by my error trapping, and
    > it seems to be randow. By random, I mean usually in the same section
    > of code, but I can run the code a few times, then it appears. I can't
    > reproduce it when I want to, and I have no idea what is causing it.
    > Any ideas ? Thanks
    > By the way the code is some record manipulation of 2 recordsets.[/color]


    Comment

    • SheldonMopes@KidNet.com

      #3
      Re: &quot;Overflow& quot; error

      Thank you, that was the problem...Just curious though, what is the
      largest Long Integer ?


      On Fri, 24 Mar 2006 11:09:02 +0800, "Allen Browne"
      <AllenBrowne@Se eSig.Invalid> wrote:
      [color=blue]
      >Overflow means that the data is too large for the data type that is trying
      >to handle it.
      >
      >Open the Immediate Window (Ctrl+G), and enter:
      > ? 200 * 200
      >The default number type in Access is Integer, and the largest integer is
      >32767. Therefore this simple calculation fails with an Overflow error. The
      >solution is to force one of the numbers to be a Long integer, e.g.:
      > ? CLng(200) * 200
      >
      >Your calculations may therefore need typecasting to a Long, Double, or
      >Currency, using CLng(), CDbl(), or CCur(). Note that these types do not
      >handle Null, so you usually need to use Nz() inside those expressions too,
      >e.g.:
      > CCur(Nz([Quantity],0)) * [PriceEach]
      >
      >More info:
      > Calculated fields misinterpreted
      >at:
      > http://allenbrowne.com/ser-45.html[/color]

      Comment

      • Randy Harris

        #4
        Re: &quot;Overflow& quot; error

        SheldonMopes@Ki dNet.com wrote:[color=blue]
        > Thank you, that was the problem...Just curious though, what is the
        > largest Long Integer ?
        >
        >
        > On Fri, 24 Mar 2006 11:09:02 +0800, "Allen Browne"
        > <AllenBrowne@Se eSig.Invalid> wrote:
        >[color=green]
        >> Overflow means that the data is too large for the data type that is trying
        >> to handle it.
        >>
        >> Open the Immediate Window (Ctrl+G), and enter:
        >> ? 200 * 200
        >> The default number type in Access is Integer, and the largest integer is
        >> 32767. Therefore this simple calculation fails with an Overflow error. The
        >> solution is to force one of the numbers to be a Long integer, e.g.:
        >> ? CLng(200) * 200
        >>
        >> Your calculations may therefore need typecasting to a Long, Double, or
        >> Currency, using CLng(), CDbl(), or CCur(). Note that these types do not
        >> handle Null, so you usually need to use Nz() inside those expressions too,
        >> e.g.:
        >> CCur(Nz([Quantity],0)) * [PriceEach]
        >>
        >> More info:
        >> Calculated fields misinterpreted
        >> at:
        >> http://allenbrowne.com/ser-45.html[/color]
        >[/color]

        From the A2K help:

        Long data type
        A fundamental data type that holds long-integer numbers. A Long variable
        is stored as a 32-bit (4-byte) number ranging in value from
        -2,147,483,648 to 2,147,483,647.


        --
        Randy Harris
        tech at promail dot com
        I'm pretty sure I know everything that I can remember.

        Comment

        Working...