How to Fix Access Aggregate Function Error After Moving to 64-Bit Windows
Question details
A Microsoft Access application throws an aggregate function error when evaluating formulas after migrating from a 32-bit to a 64-bit Windows operating system.

- Product
- Microsoft Access
- Device & OS
- Windows 11 (64-bit) / Windows 10 (32-bit)
- Scenario
- Migrating an existing Access database application that uses VBA functions and SQL Sum expressions in text controls from a 32-bit system to a new 64-bit system.
- Observed behavior
- The application fails to calculate totals, throwing aggregate function errors specifically when text controls attempt to evaluate VBA formulas like =sfl(get2bankcredits(getthisyear(),1)).
Verify whether your new installation of Microsoft Office is the 32-bit or 64-bit version, as running 64-bit Office requires specific updates to VBA API declarations compared to a 32-bit Office installation on a 64-bit OS.
Update VBA API Declarations and Compile References
If you are running the 64-bit version of Office on Windows 11, older 32-bit Windows API calls in your VBA code must be updated with the PtrSafe attribute.
VBA code designed for 32-bit Office environments relies on memory pointers that are incompatible with 64-bit Office. Updating these declarations and fixing broken reference libraries is the standard way to resolve unexpected calculation or function evaluation errors.
Open your Access database and press ALT + F11 to launch the Visual Basic for Applications editor.
Click Tools > References in the top menu. Scroll through the list and uncheck any libraries marked as 'MISSING', then re-link them to the correct 64-bit equivalents if necessary.
Search your modules for 'Declare Function'. Add the 'PtrSafe' keyword to all of them (e.g., 'Declare PtrSafe Function...') and change pointer-related 'Long' data types to 'LongPtr'.
Click Debug > Compile from the top menu. This will highlight any remaining syntax or variable type mismatch errors that are causing the aggregate function to fail.
Replace Complex SQL Aggregate Queries with DSum
If the error originates from opening recordsets using complex SQL Sum expressions, replacing them with the built-in domain aggregate function DSum() can bypass environment-specific query evaluation failures.
Reinstall 32-Bit Office on 64-Bit Windows
If your Access database contains extensive legacy VBA code that is too difficult to update, running the 32-bit version of Office on Windows 11 is fully supported and restores full compatibility.
Experience a Seamless and Lightweight Office Alternative
While Microsoft Access often requires complex VBA adjustments when switching operating systems, your everyday document, spreadsheet, and presentation needs shouldn't be this complicated. WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office, ensuring your Excel-compatible spreadsheets and documents run smoothly without heavy system demands.
- 1. Download and Install: Get the free WPS Office installer directly from the official website and run the quick installation.
- 2. Open Existing Files: Right-click your existing Microsoft Word, Excel, or PowerPoint files and select 'Open with WPS Office'.
- 3. Edit Without Formatting Loss: Enjoy full feature compatibility, including advanced spreadsheet formulas and presentation animations, with seamless saving back to standard formats.

Frequently Asked Questions
Why do VBA API declarations fail in 64-bit Windows?
If you upgrade to the 64-bit version of Office alongside 64-bit Windows, older 32-bit API declarations in VBA no longer work because the memory architecture handles pointers differently. You must update your code by adding the 'PtrSafe' keyword to your Declare statements and changing specific pointer variables to the 'LongPtr' data type.
Can I run a 32-bit Access database on a 64-bit Windows 11 machine?
Yes, 64-bit Windows operating systems include a subsystem (WOW64) that natively runs 32-bit applications. If you install the 32-bit version of Microsoft Office on your Windows 11 machine, your older Access databases and 32-bit VBA code will function exactly as they did on previous Windows versions.
What causes aggregate functions in text controls to throw errors after migration?
Moving between operating systems or Office architectures can cause missing reference libraries, or it may expose strict evaluation differences in how memory pointers process complex nested SQL expressions within recordsets. Fixing broken references or swapping SQL string evaluations with native domain aggregate functions like DSum() often resolves these issues.




