What is runtime error 6 - Overflow?

T

Tony Williams

I have a form with a tab control and on update the form compares the values
of totals on two of the pages. here is the code:

'Check Advances on page 5 with page 2
totadvances = ([txtAdv0] + [txtAdv750] + [txtAdv1500] + [txtAdv7500] +
[txtAdv15000] + [txtAdv75000] + [txtAdv150000])
totadvances2 = ([txtAdvancessole] + [txtAdvancesassetssole] +
[txtAdvancesothersole] + [txtAdvancesassetspart] + [txtAdvancesotherpart] +
[txtAdvancespart] + [txtAdvancespartnp] + [txtAdvancesassetsnp] +
[txtAdvancesothernp] + [txtAdvABLdebtsole] + [txtAdvABLdebtpart] +
[txtAdvABLdebtnp] + [txtAdvABLstocksole] + [txtAdvABLstockpart] +
[txtAdvABLstocknp] + [txtAdvABLplantsole] + [txtAdvABLplantpart] +
[txtAdvABLplantnp] + [txtAdvABLpropsole] + [txtAdvABLproppart] +
[txtAdvABLpropnp] + [txtAdvABLothersole] + [txtAdvABLotherpart] +
[txtAdvABLothernp])

If totadvances <> totadvances2 Then
strMessage = strMessage & "The total of advances on Page 5 " & _
"does not equal the total of advances on Page 2" & vbCrLf & _
"It should be " & totadvances2
End If

totadvances and totadvances2 are defined as integers and the individual
fields are defined as double format in the table.

However when I move to create a new record I get an error message that says
"Error code 6 - Overflow"

Can anyone suggest a solution?
Many thanks
Tony
 
T

Tony Williams

Soory the problem seems to be with the calculation of totadvances2 as that
line is highlighted when i click on the debug button.
Thanks
Tony
 
R

RonaldoOneNil

Overflow means that the number you are trying to assign into totadvances2 is
larger than it can hold. You have declared it as an integer which means it
can hold a maximum of 32767. Your calculation must be greater than this to
cause the error.

Tony Williams said:
Soory the problem seems to be with the calculation of totadvances2 as that
line is highlighted when i click on the debug button.
Thanks
Tony

Tony Williams said:
I have a form with a tab control and on update the form compares the values
of totals on two of the pages. here is the code:

'Check Advances on page 5 with page 2
totadvances = ([txtAdv0] + [txtAdv750] + [txtAdv1500] + [txtAdv7500] +
[txtAdv15000] + [txtAdv75000] + [txtAdv150000])
totadvances2 = ([txtAdvancessole] + [txtAdvancesassetssole] +
[txtAdvancesothersole] + [txtAdvancesassetspart] + [txtAdvancesotherpart] +
[txtAdvancespart] + [txtAdvancespartnp] + [txtAdvancesassetsnp] +
[txtAdvancesothernp] + [txtAdvABLdebtsole] + [txtAdvABLdebtpart] +
[txtAdvABLdebtnp] + [txtAdvABLstocksole] + [txtAdvABLstockpart] +
[txtAdvABLstocknp] + [txtAdvABLplantsole] + [txtAdvABLplantpart] +
[txtAdvABLplantnp] + [txtAdvABLpropsole] + [txtAdvABLproppart] +
[txtAdvABLpropnp] + [txtAdvABLothersole] + [txtAdvABLotherpart] +
[txtAdvABLothernp])

If totadvances <> totadvances2 Then
strMessage = strMessage & "The total of advances on Page 5 " & _
"does not equal the total of advances on Page 2" & vbCrLf & _
"It should be " & totadvances2
End If

totadvances and totadvances2 are defined as integers and the individual
fields are defined as double format in the table.

However when I move to create a new record I get an error message that says
"Error code 6 - Overflow"

Can anyone suggest a solution?
Many thanks
Tony
 
D

Douglas J. Steele

Integers can only hold values between -32,768 to 32,767. You're adding
together twenty-four different Integer values to get at totadvances2: if the
values are in the thousands, you're going to exceed that limit.

Try using Long Integers instead: they can hold values between -2,147,483,648
and 2,147,483,647
 
T

Tony Williams

Thanks for that, any suggestions as to what I should do to overcome that?
Thanks
Tony
PS I'll be off line for 24 hours now

RonaldoOneNil said:
Overflow means that the number you are trying to assign into totadvances2 is
larger than it can hold. You have declared it as an integer which means it
can hold a maximum of 32767. Your calculation must be greater than this to
cause the error.

Tony Williams said:
Soory the problem seems to be with the calculation of totadvances2 as that
line is highlighted when i click on the debug button.
Thanks
Tony

Tony Williams said:
I have a form with a tab control and on update the form compares the values
of totals on two of the pages. here is the code:

'Check Advances on page 5 with page 2
totadvances = ([txtAdv0] + [txtAdv750] + [txtAdv1500] + [txtAdv7500] +
[txtAdv15000] + [txtAdv75000] + [txtAdv150000])
totadvances2 = ([txtAdvancessole] + [txtAdvancesassetssole] +
[txtAdvancesothersole] + [txtAdvancesassetspart] + [txtAdvancesotherpart] +
[txtAdvancespart] + [txtAdvancespartnp] + [txtAdvancesassetsnp] +
[txtAdvancesothernp] + [txtAdvABLdebtsole] + [txtAdvABLdebtpart] +
[txtAdvABLdebtnp] + [txtAdvABLstocksole] + [txtAdvABLstockpart] +
[txtAdvABLstocknp] + [txtAdvABLplantsole] + [txtAdvABLplantpart] +
[txtAdvABLplantnp] + [txtAdvABLpropsole] + [txtAdvABLproppart] +
[txtAdvABLpropnp] + [txtAdvABLothersole] + [txtAdvABLotherpart] +
[txtAdvABLothernp])

If totadvances <> totadvances2 Then
strMessage = strMessage & "The total of advances on Page 5 " & _
"does not equal the total of advances on Page 2" & vbCrLf & _
"It should be " & totadvances2
End If

totadvances and totadvances2 are defined as integers and the individual
fields are defined as double format in the table.

However when I move to create a new record I get an error message that says
"Error code 6 - Overflow"

Can anyone suggest a solution?
Many thanks
Tony
 
T

Tony Toews [MVP]

Tony Williams said:
Thanks for that, any suggestions as to what I should do to overcome that?

You'll probably want to define that as a Currency. But you should
really be reading up on data types and understand how they work to
make up your own mind.

Tony
 
T

Tony Toews [MVP]

Tony Williams said:
'Check Advances on page 5 with page 2
totadvances = ([txtAdv0] + [txtAdv750] + [txtAdv1500] + [txtAdv7500] +
[txtAdv15000] + [txtAdv75000] + [txtAdv150000])
totadvances2 = ([txtAdvancessole] + [txtAdvancesassetssole] +
[txtAdvancesothersole] + [txtAdvancesassetspart] + [txtAdvancesotherpart] +
[txtAdvancespart] + [txtAdvancespartnp] + [txtAdvancesassetsnp] +
[txtAdvancesothernp] + [txtAdvABLdebtsole] + [txtAdvABLdebtpart] +
[txtAdvABLdebtnp] + [txtAdvABLstocksole] + [txtAdvABLstockpart] +
[txtAdvABLstocknp] + [txtAdvABLplantsole] + [txtAdvABLplantpart] +
[txtAdvABLplantnp] + [txtAdvABLpropsole] + [txtAdvABLproppart] +
[txtAdvABLpropnp] + [txtAdvABLothersole] + [txtAdvABLotherpart] +
[txtAdvABLothernp])

Are advances a dollar amount or what? If a dollar amount then they
should likely be a currency. If not tell us a bit more about what
these are.

Tony
 
Top