logo
search
Office Compatibility Issues

How to Fix Access Aggregate Function Error After Moving to 64-Bit Windows

Anum MushtaqAnum Mushtaq Oct 26, 2026 869 views

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.

How to Fix Access Aggregate Function Errors in 64-Bit Windows
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)).
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Open your Access database and press ALT + F11 to launch the Visual Basic for Applications editor.

2
Check Reference Libraries

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.

3
Update API Declarations

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'.

4
Compile the Database

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.

Data Type Changes: Only update variables to LongPtr if they specifically hold memory addresses or window handles (hWnd). Standard numeric calculations should remain as Long.
Free Microsoft Office alternative

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. 1. Download and Install: Get the free WPS Office installer directly from the official website and run the quick installation.
  2. 2. Open Existing Files: Right-click your existing Microsoft Word, Excel, or PowerPoint files and select 'Open with WPS Office'.
  3. 3. Edit Without Formatting Loss: Enjoy full feature compatibility, including advanced spreadsheet formulas and presentation animations, with seamless saving back to standard formats.
Fully compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint (.pptx) formats.Built-in PDF editor for effortless document conversion, merging, and editing.Lightweight architecture that consumes minimal system memory compared to heavy legacy suites.Familiar user interface design ensuring zero learning curve for traditional Office users.
microsoft office alternative - wps office

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.