Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Arithmetic Error -- Converting Expression to Int -- Weird Behavior

I'm experiencing the nuisance that is the "arithmetic overflow converting
expression to int" error, but I'm not seeing this error consistently enough
to think there's something wrong with my code.

Here's the snippet:
select round((sum(gu)/50000),2) as gu_aal,
round((sqrt(((50000*sum(gu_square))-square(sum(gu)))/(50000*49999))),2) as
gu_stdev

The first field is basically an average, while the second is a specialized
standard deviation.

I use a bit of VBA to extract the result of this query. So, when I hit the
play button to let the function run, the error pops up and stops my function
dead. But, when I hit F8 and step through the function, it works perfectly.
To me, that makes no sense. The code never changes, so why would it run using
one method but not the other?

Can anyone shed some light on this problem?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Arithmetic Error -- Converting Expression to Int -- Weird Behavior

Why not use a long ?
Without seeing the vba it's difficult to guess why F8 makes a difference.

Tim

"Chris C" wrote in message
...
I'm experiencing the nuisance that is the "arithmetic overflow converting
expression to int" error, but I'm not seeing this error consistently
enough
to think there's something wrong with my code.

Here's the snippet:
select round((sum(gu)/50000),2) as gu_aal,
round((sqrt(((50000*sum(gu_square))-square(sum(gu)))/(50000*49999))),2) as
gu_stdev

The first field is basically an average, while the second is a specialized
standard deviation.

I use a bit of VBA to extract the result of this query. So, when I hit the
play button to let the function run, the error pops up and stops my
function
dead. But, when I hit F8 and step through the function, it works
perfectly.
To me, that makes no sense. The code never changes, so why would it run
using
one method but not the other?

Can anyone shed some light on this problem?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Arithmetic Error -- Converting Expression to Int -- Weird Beha

Here is the full snippet:

' --------- Mean Aggregate GU AAL
If intYear = 50000 Then
query = "select round((sum(gu)/50000),2) as gu_aal,
round((sqrt(((50000*sum(gu_square))-square(sum(gu)))/(50000*49999))),2) as
gu_stdev "
Else
query = "select round((sum(gu)/10000),2) as gu_aal,
round((sqrt(((10000*sum(gu_square))-square(sum(gu)))/(10000*9999))),2) as
gu_stdev "
End If
query = query & "from mean_gu_agg_aal_working"

resultset.ActiveConnection = cnPubs
resultset.Open query

Sheet6.Range("D5:E5").CopyFromRecordset resultset

resultset.Close

-- Does that help?


"Tim Williams" wrote:

Why not use a long ?
Without seeing the vba it's difficult to guess why F8 makes a difference.

Tim

"Chris C" wrote in message
...
I'm experiencing the nuisance that is the "arithmetic overflow converting
expression to int" error, but I'm not seeing this error consistently
enough
to think there's something wrong with my code.

Here's the snippet:
select round((sum(gu)/50000),2) as gu_aal,
round((sqrt(((50000*sum(gu_square))-square(sum(gu)))/(50000*49999))),2) as
gu_stdev

The first field is basically an average, while the second is a specialized
standard deviation.

I use a bit of VBA to extract the result of this query. So, when I hit the
play button to let the function run, the error pops up and stops my
function
dead. But, when I hit F8 and step through the function, it works
perfectly.
To me, that makes no sense. The code never changes, so why would it run
using
one method but not the other?

Can anyone shed some light on this problem?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Arithmetic Error -- Converting Expression to Int -- Weird Beha

When something works when stepping through but doesn't when run directly it
often means there's some part of the process which is running asynchronously
with the rest. I'm not sure what that would be in your case though.

Where is the error coming from - ie. which line ? Is it coming from VBA or
is it a database error ?

Tim

"Chris C" wrote in message
...
Here is the full snippet:

' --------- Mean Aggregate GU AAL
If intYear = 50000 Then
query = "select round((sum(gu)/50000),2) as gu_aal,
round((sqrt(((50000*sum(gu_square))-square(sum(gu)))/(50000*49999))),2) as
gu_stdev "
Else
query = "select round((sum(gu)/10000),2) as gu_aal,
round((sqrt(((10000*sum(gu_square))-square(sum(gu)))/(10000*9999))),2) as
gu_stdev "
End If
query = query & "from mean_gu_agg_aal_working"

resultset.ActiveConnection = cnPubs
resultset.Open query

Sheet6.Range("D5:E5").CopyFromRecordset resultset

resultset.Close

-- Does that help?


"Tim Williams" wrote:

Why not use a long ?
Without seeing the vba it's difficult to guess why F8 makes a difference.

Tim

"Chris C" wrote in message
...
I'm experiencing the nuisance that is the "arithmetic overflow
converting
expression to int" error, but I'm not seeing this error consistently
enough
to think there's something wrong with my code.

Here's the snippet:
select round((sum(gu)/50000),2) as gu_aal,
round((sqrt(((50000*sum(gu_square))-square(sum(gu)))/(50000*49999))),2)
as
gu_stdev

The first field is basically an average, while the second is a
specialized
standard deviation.

I use a bit of VBA to extract the result of this query. So, when I hit
the
play button to let the function run, the error pops up and stops my
function
dead. But, when I hit F8 and step through the function, it works
perfectly.
To me, that makes no sense. The code never changes, so why would it run
using
one method but not the other?

Can anyone shed some light on this problem?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
weird listbox behavior Bill Grigg Excel Programming 0 August 25th 08 03:42 PM
weird listbox behavior Bill Excel Programming 9 August 25th 08 02:51 PM
Weird Do...Until behavior... IT_roofer Excel Programming 0 May 23rd 07 06:34 PM
Weird Arithmetic Error Keith Excel Discussion (Misc queries) 7 February 7th 06 06:30 PM
Weird Sorting Behavior Jim Thomlinson[_3_] Excel Programming 1 May 4th 05 04:42 AM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"