The code in this project must be updated for use on 64-bit system (1 Viewer)

masoud_sedighy

Registered User.
Local time
Today, 03:51
Joined
Dec 10, 2011
Messages
132
in my database i have imported several modules like (modAPI,modReportToPDF,ComDlg) from one trusted sample database.

when i am working with my database on laptop it works without problem.but when copy it on another computer i got error ("The code in this project must be updated for use on 64-bit system")

<code>

' Always alias API function names
' in case a library declares the same funtions
' Function to close an opened key
Declare Function IO11_RegCloseKey Lib "advapi32.dll" Alias _
"RegCloseKey" (ByVal hKey As Long) As Long
' Function to open a key and get its handle
Declare Function IO11_RegOpenKeyEx Lib "advapi32.dll" Alias _
"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As _
Long) As Long
' Function to fetch a Long (DWORD) key value
Declare Function IO11_RegQueryValueExLong Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, lpData As _
Long, lpcbData As Long) As Long
' Function to fetch a key data type and length
Declare Function IO11_RegQueryValueExNULL Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
As Long, lpcbData As Long) As Long
' Function to fetch a String key value
Declare Function IO11_RegQueryValueExString Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
As String, lpcbData As Long) As Long
</code>

please help how i can solve this problem.
 

Orthodox Dave

Home Developer
Local time
Today, 11:51
Joined
Apr 13, 2017
Messages
218
Hi Masoud,

Looking over nhorton79's link, this seems a pretty long and complex article. A bit of a bombshell actually - complete news to me.

It would seem your laptop has 32-bit Access installed and the other computer has 64-bit Access. If it is possible, I suggest uninstalling 64-bit Access from the computer and reinstalling it as 32-bit, then you won't have the compatibility problem. If it's a work computer or network, you'll have to try and persuade your IT guys to do this.

If you were unaware your existing databases would be incompatible, it would seem perfectly logical to install 64 bit Access on a 64 bit operating system. Microsoft haven't exactly been trumpeting this incompatibility problem.

If you can't change the Computer's Access to 32-bit, try googling "convert 32 bit vba to 64 bit" - there are lots of anxious threads about this problem, and some solutions too. Good luck!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:51
Joined
May 7, 2009
Messages
19,230
Merely changing the function or sub declaration doesn't guarantee that your code will work. You have to change also the code that consume these routine.
 

Orthodox Dave

Home Developer
Local time
Today, 11:51
Joined
Apr 13, 2017
Messages
218
I wonder how many developers are aware of this problem. Anyone exporting databases to other companies could have compatibility problems. One of Microsoft's suggestions is:
You can contact the vendor for an updated version
It would have been better if Microsoft had provided a conversion tool themselves. They are usually pretty good at providing for upward/downward compatibility.
 

isladogs

MVP / VIP
Local time
Today, 11:51
Joined
Jan 14, 2017
Messages
18,213
I wonder how many developers are aware of this problem. Anyone exporting databases to other companies could have compatibility problems. One of Microsoft's suggestions is:

It would have been better if Microsoft had provided a conversion tool themselves. They are usually pretty good at providing for upward/downward compatibility.

I think you'll find that developers creating databases for external use / sale will know about this - if only by finding out the hard way.

For the past 6 years, I've had to convert all my commercial databases for 32/64 bit due to a small customer base that works in 64-bit

There are 4 main things to consider:
a) Not all ActiveX controls work in 64-bit systems.
That one of the reasons I avoid them as far as possible

Amongst those that don't are FlexGrid, Treeview(?)
Windows Common Controls also cause problems

b) All API declarations need to be modified as already explained : PtrSafe & LongPtr
This link is for a very good article by AWF member sonic8
http://codekabinett.com/rdumps.php?Lang=2&targetDoc=windows-api-declaration-vba-64-bit

For simplicity, I use a 'blanket approach' converting all Long to LongPtr though that isn't the correct way to do it.
However its never yet failed for me!

c) Check for other code issues
However, in my experience almost all code will convert successfully if a) & b) have been done.
So far I've only had 2 issues that needed solving:
i) a custom ribbon built using ribbon creator software (workround done)
ii) a masked input box (not solved!)

d) If you release databases as ACCDB these work in both 32/64 bit systems if all the above are done.
However if you use ACCDE files a separate version MUST be created for each bitness
 

Orthodox Dave

Home Developer
Local time
Today, 11:51
Joined
Apr 13, 2017
Messages
218
Colin, that is really helpful - thanks a lot. As a semi-retired old boy, I am developing a database from home that I don't even know will sell, but if it does, 64-bit could cause a problem.

Just to clarify, are you saying that your code will run in both 32 and 64 environments? e.g. can you use PtrSafe and LongPtr in a 32-bit environment as well?
 

isladogs

MVP / VIP
Local time
Today, 11:51
Joined
Jan 14, 2017
Messages
18,213
Just to clarify, are you saying that your code will run in both 32 and 64 environments? e.g. can you use PtrSafe and LongPtr in a 32-bit environment as well?

Yes - provided you use conditional compiling (and its not an ACCDE)

Code:
#If Win64 Then
'64-bit declarations here (PtrSafe & LongPtr)
#Else
'32-bit declarations here
#End If

If you also need it to work in pre-2007 then one extra step is needed:

Code:
#If VBA7 Then
'add PtrSafe
ElseIf Win64 Then
'64-bit declarations here (PtrSafe & LongPtr)
#Else
'32-bit declarations here
#End If


Most of my items in sample databases / code repository work in both bitnesses. For example, try this one:

https://www.access-programmers.co.uk/forums/showpost.php?p=1539350&postcount=3
 

Users who are viewing this thread

Top Bottom