Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access 64-bit compile error: “must be updated for use on 64-bit systems” (PtrSafe)

The message appears as soon as a form opens on a PC with 64-bit Office. It is not a bug in the application, but calls to Windows written for 32-bit Office, which the 64-bit compiler rejects.

The message

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.

64-bit Access, English

On a French Access: « Le code contenu dans ce projet doit être mis à jour pour pouvoir être utilisé sur les systèmes 64 bits… »

Where it shows up

In any VBA module that contains a Declare statement (a direct call to a Windows function: GetUserName, ShellExecute, GetOpenFileName, Sleep…). Since the compiler rejects the whole module, the form, the button or the entire application stops.

Common causes

  • Declare statements without PtrSafe, written before Office 2010;
  • Long used for handles or addresses (hWnd, hDC, pointers): with PtrSafe alone the code compiles but may crash, because those values are 64-bit;
  • a library or ActiveX control that only exists in 32-bit — a different cause with the same effects (“Can't find project or library”).

How to reproduce and check it

  1. In the VBA editor on 64-bit Office, Debug > Compile: the first rejected statement is highlighted.
  2. Search for “Declare” across the project (Edit > Find, “Current Project”): every hit without “PtrSafe” needs work.
  3. On 32-bit Office the message never appears: searching for Declare is how you know what will break.

How to fix it

Add PtrSafe and use LongPtr for handles and pointers:

Before: Declare Function GetActiveWindow Lib "user32" () As Long — after: Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr.

To keep a version that also runs on Office 2007 and earlier, wrap both forms: #If VBA7 Then (declaration with PtrSafe) #Else (old declaration) #End If. Check each signature against the Windows function's documentation: only handles and addresses become LongPtr.

What Auscult reports

The diagnostic reads the code and lists every Declare without PtrSafe, with its module, line and name, as a high longevity risk — even when the analysis runs on 32-bit Office. The full report gives today's line and the suggested line for each one. On 64-bit Office, the forms, reports and buttons that depend on them are marked “fails on 64-bit Office”: one cause, counted once.

Measured on our test corpus: this message was recorded while analysing 61 of 965 applications.

The Access error reference, code by code

Frequently asked questions

Is adding PtrSafe everywhere enough?

To compile, yes; to work, not always. A handle or address left as Long is truncated on 64-bit and can crash Access. Each declaration should be checked against the Windows function's signature.

Can we stay on 32-bit Office?

Yes, Microsoft still offers it at install time. But 64-bit has been the default since Office 2019 and Microsoft 365: every new or reinstalled PC is likely to get it.

Where are the other errors in your application hiding?

The diagnostic runs on your computer, on a copy of the application, without sending the data in your tables. The health grade and the summary are free.