Some users here now have whiz-bang new Surface Pros running Windows 10 64 bit, and 64 bit Office.
When they try to use the Access database I look after, they get a "the code in this project must be updated for use on 64-bit systems" error.
Reading on this forum and elsewhere, this relates to Declare statements.
This post pointed me to fixing the immediate issue, by wrapping the declare functions thus:
To save anyone else wondering what the Win64 is, it's apparently a "compiler constant" set by the environment.
Whether the Longs need to be changed to LongLong or LongPtr, or can be left as Long, seems rather opaque, and apparently varies from API to API. I was intending trying each in turn, but for this example, Access seems happy enough with leaving it as just Long.
I'm intrigued why our lovely friends at Microsoft decided that merely adding "PtrSafe" should make it work in a 64-bit environment, rather than just having VBA assume PtrSafe...
Has anyone come across any other gotchas with using Access in a mixed 32-bit and 64-bit environment?
When they try to use the Access database I look after, they get a "the code in this project must be updated for use on 64-bit systems" error.
Reading on this forum and elsewhere, this relates to Declare statements.
This post pointed me to fixing the immediate issue, by wrapping the declare functions thus:
Code:
#If Win64 Then
Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal IpBuffer As String, nSize As Long) As Long
Private Declare PtrSafe Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
#Else
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal IpBuffer As String, nSize As Long) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
#End If
To save anyone else wondering what the Win64 is, it's apparently a "compiler constant" set by the environment.
Whether the Longs need to be changed to LongLong or LongPtr, or can be left as Long, seems rather opaque, and apparently varies from API to API. I was intending trying each in turn, but for this example, Access seems happy enough with leaving it as just Long.
I'm intrigued why our lovely friends at Microsoft decided that merely adding "PtrSafe" should make it work in a 64-bit environment, rather than just having VBA assume PtrSafe...
Has anyone come across any other gotchas with using Access in a mixed 32-bit and 64-bit environment?