Kaprice
asked on
MS Access VBA odd Overflow error
Check out this code:
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?
Dim lngInterval As Long
lngInterval = 1 * 60 * 1000
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?
Public Function Test() As Long
Dim lng as Long
lng = (1*60)
lng = lng * 1000
Test = lng
End Function
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll try that, but recall that I also tried 60 * 1000 and got the same error.
ASKER
Funny. clng(1) * 60 * 1000 worked, even though 60 * 1000 does not. Any explanation as to why?
try
lngInterval = clng(60) * 1000
lngInterval = clng(60) * 1000
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
see this link from Microsoft
https://msdn.microsoft.com/en-us/library/aa264525%28v=vs.60%29.aspx?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/en-us/library/aa264525%28v=vs.60%29.aspx?f=255&MSPPError=-2147217396
ASKER
Open in new window
works just fine.