“The Code in This Project Must Be Updated for Use on 64-Bit Systems”
The full message reads: “The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PtrSafe attribute.”
This happens when a database written for 32-bit Office is opened in 64-bit Office. Microsoft 365 now installs 64-bit Office by default, so many older databases start failing the moment a company replaces its computers or upgrades Office.
Common causes
- VBA code calls Windows functions using
Declarestatements written for 32-bit Office - The database uses 32-bit-only ActiveX controls or add-ins
- The database is an .accde or .mde compiled in 32-bit Office, which can’t run in 64-bit Office
How to fix it
- Open the VBA editor (Alt+F11) and search the project for
Declare. - Add
PtrSafeto each declaration, soDeclare FunctionbecomesDeclare PtrSafe Function. - Change pointer and handle variables (window handles, memory addresses) from
LongtoLongPtr. Adding PtrSafe alone silences the error, but the code can still crash if these types aren’t updated. - If some users are still on 32-bit Office, wrap the declarations in
#If VBA7 Then ... #Else ... #End Ifblocks so the same file works on both. - Go to Debug > Compile and fix anything else it flags.
- For an .accde file, recompile it from the original .accdb using 64-bit Office.
This one is easy to get wrong
Updating Declare statements requires knowing which variables are pointers. A wrong guess can compile cleanly and still cause random crashes later. If your database has a lot of Windows API code, have someone experienced review it.
Need help with a 64-bit upgrade?
Updating legacy Access code for 64-bit Office is a regular part of our VBA Debugging & Enhancement work. Book a free diagnostic to get an estimate.
