Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Overflow Error (2002)

    I have an after update event that is supposed to calculate the annual salary by multiplying the contract salary by the FTE (full-time equivalent). If a person is full time 1.000 then there is no problem but sometimes when the FTE is less than full time then the calculation gives a "runtime error '6' Overflow" message. For example the contract salary is $67,815 and the FTE is .50, I get the error. From what I read, the overflow message would mean the answer would be too large but in this case the answer should be half the size of the contract salary. How can I trap for this error and is there something I could do to prevent it?
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Overflow Error (2002)

    What data types are you using in the calculation, Judy? You'll also get an overflow error if your datatype won't hold the result of the calculation. If you post the code for the calculation, we might be able to spot the problem.
    Charlotte

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Overflow Error (2002)

    This error can occur when the numbers are too large for the variables you are using for the calculations.

    For example if you have declared a variables as an integer, when it needs to be a long integer, it will work OK if the numbers are small, but give overflow if the numbers get too large.

    Can you post the code you are using in the event.
    Regards
    John



  4. #4
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Overflow Error (2002)

    Private Sub Combo50_AfterUpdate()
    Dim TFTE As Single
    Dim PTSal As Integer
    Dim PTSal5 As Integer
    Dim PTPerDiem As Single
    TFTE = Me.TotalFTE

    Me.Step = Me.Combo50.Column(2)
    Me.GradeStep1 = Me.Combo50.Column(1) & "/" & Me.Combo50.Column(2)
    Me.ContractSalary = Me.Combo50.Column(3)
    Me.PerDiem = Me.Combo50.Column(4)

    If TFTE < 1 Then
    PTSal = Me.ContractSalary * TFTE
    PTSal5 = PTSal * 1.05
    Me.ContractSalary = PTSal5
    PTPerDiem = PTSal5 / NoDays
    Me.PerDiem = PTPerDiem
    Me.ActualSalary.Requery
    End If
    End Sub
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Overflow Error (2002)

    You have declared PTSal and PTSal5 as Integers, i.e. whole numbers in the range -32768 to +32767. You should declare them as Single, Double or Currency (and use the same type for TFTE and PTPerDiem)

  6. #6
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Overflow Error (2002)

    Thank you all very much. Just changing the variables from integer to single did the trick. I wanted whole numbers without decimals that is why I used integer. But now I understand that Access could not even complete the calculation because I had used integer. The records where it had worked apparently did not need to carry the answer out to where it needed to use decimal places.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •