Link to home
Start Free TrialLog in
Avatar of Kaprice
KapriceFlag for United States of America

asked on

MS Access VBA odd Overflow error

Check out this code:

Dim lngInterval As Long
  lngInterval = 1 * 60 * 1000

Open in new window


I'm getting an Overlow error. Why would that be?

BTW, if I go to the Immediate window and type ?1 * 60 * 1000, I also get an overflow error.

In fact, ?60 * 1000 in the immediate window gives the overflow error.

I've check Tools | References and nothing is MISSING.

This is messed up, right? Anyone know how to fix this?
Avatar of Kaprice
Kaprice
Flag of United States of America image

ASKER

Changing the code to

Dim lngInterval As Long
  lngInterval = 60000

Open in new window


works just fine.
Public Function Test() As Long

     Dim lng as Long
     lng = (1*60)
     lng = lng * 1000
     Test = lng

End Function

Open in new window


Put that in a Module and type ? Test in the immediate window.  I get 60000 as out put.  However, when I attempted to assign in one step, I too got the overflow error.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kaprice

ASKER

I'll try that, but recall that I also tried 60 * 1000 and got the same error.
Avatar of Kaprice

ASKER

Funny. clng(1) * 60 * 1000 worked, even though 60 * 1000 does not. Any explanation as to why?
try
 lngInterval = clng(60) * 1000
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial