Code Must Be Updated for 64-Bit Systems

Short answer: This error means your database’s VBA code was written for 32-bit Office and you’re now running 64-bit Office. Fix it by adding the PtrSafe keyword to every Declare statement and changing pointer and handle variables to LongPtr. If the file is a compiled .accde or .mde, it has to be recompiled from the original .accdb in 64-bit Access.

Reviewed by Anthony Passeri, MBA, certified Microsoft Access Expert with 21+ years of Access development.

What the Error Looks Like

When you open the database or click a button, Access stops with:

Compile error: 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.

It usually appears right after Office is upgraded or reinstalled. Microsoft now installs 64-bit Office by default, so many businesses hit this error without realizing their Office version changed.

Why It Happens

Many older Access databases call Windows functions directly using Declare statements in VBA, for things like file dialogs, getting the user name or working with windows. Those statements were written for 32-bit Office, where memory addresses (pointers) are 32 bits. In 64-bit Office, pointers are 64 bits, so Access refuses to run the old declarations until they’re updated.

Step 1: Confirm Which Office You Have

In Access, go to File > Account > About Access. The first line shows whether you’re running 32-bit or 64-bit. Microsoft explains the differences in Choose between the 64-bit or 32-bit version of Office.

Step 2: Back Up and Open the Code

  1. Make a copy of the database and work on the copy.
  2. Open it holding Shift to skip startup forms and code.
  3. Press Alt+F11 to open the VBA editor.
  4. Press Ctrl+F, search for Declare, and choose Current Project so you find every one.

Step 3: Add PtrSafe to Every Declare Statement

Add the PtrSafe keyword after Declare:

' Before (32-bit only)
Declare Function GetActiveWindow Lib "user32" () As Long

' After
Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr

Step 4: Change Pointers and Handles to LongPtr

Adding PtrSafe only tells Access the statement has been reviewed. It doesn’t make the code correct. Any parameter or return value that holds a pointer or handle (often named hWnd, hDC, hInstance or ending in Ptr) must change from Long to LongPtr. Ordinary numbers stay Long.

LongPtr automatically becomes a 32-bit Long in 32-bit Office and a 64-bit LongLong in 64-bit Office, so the same code works in both. Also update any VBA variables that receive those values. Microsoft’s 64-bit VBA overview explains the rules.

Getting types wrong here doesn’t always cause an error; it can cause crashes or wrong results later, so test carefully.

Step 5: Support Very Old Access Versions (If Needed)

PtrSafe works in Access 2010 and later in both 32-bit and 64-bit. If anyone still opens the database in Access 2007 or earlier, wrap the declarations in conditional compilation:

#If VBA7 Then
    Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr
#Else
    Declare Function GetActiveWindow Lib "user32" () As Long
#End If

Those old versions are long unsupported; see Is Microsoft Access Still Supported?

Step 6: Compile and Test

In the VBA editor, choose Debug > Compile and fix anything it flags. Then test every form and button that uses the updated code. If compiling stops on a missing reference instead, see Compile Error: Can’t Find Project or Library.

Two Traps Most Guides Miss

Compiled .accde or .mde Files

A database compiled into an .accde or .mde file in 32-bit Office won’t run in 64-bit Office, and vice versa. You can’t edit its code, so you need the original .accdb: open it in 64-bit Access, update the code, then compile a new .accde. If the original is lost, the code may need to be rebuilt.

Old ActiveX Controls and Add-ins

Some older ActiveX controls (like certain calendar or tree-view controls) and third-party add-ins were never released in 64-bit versions. They show up as broken controls or errors when the form opens, and need to be replaced with built-in Access features or 64-bit-compatible alternatives.

The Quick Workaround: Switch Back to 32-Bit Office

If the database is business-critical and you need it working today, you can uninstall 64-bit Office and reinstall the 32-bit version. Both can’t be installed side by side. This buys time but isn’t a long-term fix: the code still needs updating, and 64-bit is Microsoft’s default going forward.

When to Get Help

A database with a few Declare statements is a quick fix. Databases with dozens of API calls, compiled files without the original, or code nobody understands take longer. Our VBA debugging and enhancement service handles 64-bit conversions regularly, and our legacy system documentation service maps out what old code actually does. For ongoing help, see maintenance and support.

If your database leans heavily on VBA and you’re planning its future, see Power Apps vs SQL Server vs Staying in Access. If code won’t run at all after the fix, check that the file is in a trusted location (macros blocked); setting one up is covered in Getting Started with Microsoft Access.

Upgraded Office and now your database won’t run? Book a free diagnostic and we’ll tell you how big the 64-bit fix is.

Frequently Asked Questions

How do I fix “The code in this project must be updated for use on 64-bit systems”?

Add the PtrSafe keyword to every Declare statement in your VBA code, change pointer and handle variables from Long to LongPtr, then compile and test.

Is adding PtrSafe enough?

No. PtrSafe stops the error, but pointers and handles must also use LongPtr. Otherwise the code can crash or return wrong values in 64-bit Office.

Why won’t my .accde file open in 64-bit Access?

Files compiled to .accde or .mde in 32-bit Office can’t run in 64-bit Office. Recompile them from the original .accdb file in 64-bit Access.

Should I install 32-bit or 64-bit Office for Access?

64-bit is Microsoft’s default and the better long-term choice. Use 32-bit only if you depend on old code, add-ins or controls that haven’t been updated yet.

Talk to an Access Expert

Not sure what this means for your database? Book a free diagnostic call. No sales pitch, just a straight conversation about what makes sense for your situation.

Book a Free Diagnostic

Phone: 623-267-5720

Email: info@accessevolved.com

Access Evolved | 19580 W Indian School Rd, Ste 105 #815, Buckeye, AZ 85396

Sources

Scroll to Top