vba error 6 overflow

  • Thread starter Thread starter tinybears
  • Start date Start date
T

tinybears

Hey,

In my userform I calculate formulas that come into my Access database.
These are doubles, so when I fill in 0 I get error 13 saying I can't
fill that i because that will cause an overflow. When I try with with
errormessages to get passed error 13 I get the overflow problem. My
problem is that sometimes it should be possible to fill in 0 but that
my formula then sets it's value tot 0 or something.

Is there someone who could help me out with this?

This is an example of a line with a formula:

rs!Acid_test = (CDbl(TekstVla) - CDbl(TekstVVKT)) / CDbl(TekstVoor)

So when I fill in 0 in the textbox on the userform for TekstVoor I got
stuck.

thx in advace
 
tinybears said:
Hey,

In my userform I calculate formulas that come into my Access database.
These are doubles, so when I fill in 0 I get error 13 saying I can't
fill that i because that will cause an overflow. When I try with with
errormessages to get passed error 13 I get the overflow problem. My
problem is that sometimes it should be possible to fill in 0 but that
my formula then sets it's value tot 0 or something.

Is there someone who could help me out with this?

This is an example of a line with a formula:

rs!Acid_test = (CDbl(TekstVla) - CDbl(TekstVVKT)) / CDbl(TekstVoor)

So when I fill in 0 in the textbox on the userform for TekstVoor I got
stuck.

The problem is, there is no valid value for this to produce when
TekstVoor is 0. You can't divide by 0. It's not defined. It's not
even defined when the numerator is 0. Excel is doing the
correct thing by giving you an error message.

If you want to be able to handle user input of 0 for this variable,
you need to put in a test for 0, and use a formula that does
not divide by 0 to handle that case. Probably what you want
is to check if abs(TekstVoor) is less than some value, say
1E-10 or something, and if it is, then use a formula that does
not have 1/TekstVoor in it.
Socks
 
I think I'd just check to make sure that the value in TekstVoor is non-zero.
I'm not sure what should happen, but dividing by 0 is usually a bad idea.


dim res as variant

res = "Error!

if isnumeric(tekstvla.value) _
and isnumeric(tekstvvkt.value) _
and isnumeric(tekstvoor.value) then
if cdbl(ekstvoor.value) <> 0 then
res = (CDbl(TekstVla.value) - CDbl(TekstVVKT.value)) _
/ CDbl(TekstVoor.value)
end if
end if

worksheets("rs").range("Acid_test").value = res
 
hey thx,

I solved it something like this:

If TekstVoor = 0 Then
rs!Acid_test = 0
TekstVoor = 0
Else
rs!Acid_test = (CDbl(TekstVla) - CDbl(TekstVVKT)) / CDbl(TekstVoor)
End If

greetz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top