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.
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
Declarestatements withoutPtrSafe, written before Office 2010;Longused for handles or addresses (hWnd,hDC, pointers): withPtrSafealone 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
- In the VBA editor on 64-bit Office, Debug > Compile: the first rejected statement is highlighted.
- Search for “Declare” across the project (Edit > Find, “Current Project”): every hit without “PtrSafe” needs work.
- On 32-bit Office the message never appears: searching for
Declareis 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.