Jul 27 2024 08:23 PM
This Access VBA code is giving me an overflow error. What am I doing wrong?
Dim chunkSize As Long
chunkSize = 320 * 1024
Also, I tried changing chunkSize to a Double, but got the same overflow error.
Jul 27 2024 10:41 PM
Jul 28 2024 09:13 AM
Jul 28 2024 09:54 AM - edited Jul 28 2024 09:56 AM
You can get the specs for Access datatypes from these articles:
https://support.microsoft.com/en-us/office/data-types-for-access-desktop-databases-df2b83ba-cef6-436...
https://support.microsoft.com/en-us/office/set-the-field-size-ba65e5a7-2e6f-4737-8e72-36b93f966a33
A Long Integer can be from -2,147,483,648 to +2,147,483,647. Storage requirement is four bytes.
320 * 1024 = 327,680
That's well within the range.
And Integer, on the other hand, can be from -32,768 to +32,767. Storage requirement is two bytes.
I wonder if you are actually working with an Integer, not a Long Integer, in this context. Please validate that. I know you showed the variable dimmed as a Long, but this sure smells like an integer problem.
Jul 28 2024 04:12 PM
Jul 29 2024 04:34 AM - edited Jul 30 2024 09:13 AM
SolutionHi,
You are not the first to wonder about the VBA behaviour to "coerce" numbers into an integer. Have a look at the very similar example in the error documentation: Overflow (Error 6)
Servus
Karl
****************
Access News, Forever, DevCon
Access-Entwickler-Konferenz AEK - 19./20.10. Nürnberg
Jul 29 2024 04:34 AM - edited Jul 30 2024 09:13 AM
SolutionHi,
You are not the first to wonder about the VBA behaviour to "coerce" numbers into an integer. Have a look at the very similar example in the error documentation: Overflow (Error 6)
Servus
Karl
****************
Access News, Forever, DevCon
Access-Entwickler-Konferenz AEK - 19./20.10. Nürnberg