logo
search
Others

Fix Access Query Returning #Error in Multi-Year Calculations

Algirdas JasaitisAlgirdas Jasaitis Sep 28, 2026 870 views

Question details

The user needs to fix an MS Access query that successfully calculates early years but begins returning an #Error around year 26 when calculating financial results for a 30-year span.

How to Fix Access Query Returning #Error After Repeated Year Calculations
Product
Microsoft Access
Device & OS
not provided
Scenario
Calculating 30-year financial results in a database using repeating column fields where each year references the previously calculated year's value.
Observed behavior
The query fails and outputs an #Error around the 26th year due to expression complexity limits and a denormalized spreadsheet-style table design.
Before you start

Before modifying your database structure or writing VBA code, ensure you have created a complete backup copy of your Access database (.accdb or .mdb file) to prevent accidental data loss.

Solution 1Recommended

Normalize Your Database Tables

Transform your spreadsheet-style columns into a normalized relational table format where each year is represented as a separate row to avoid query complexity limits.

The core issue is a denormalized, spreadsheet-style database design. Storing each year as a separate column (e.g., Year1, Year2... Year30) forces the query to use deeply nested, recursive expressions. Access has a strict limit on expression complexity, which is why it fails around year 26.

By moving from a column-based design to a row-based design, you eliminate the complexity limit and make the database easier to maintain.

1
Create a related table

Navigate to the Create tab and design a new table with three fields: a Foreign Key (linking to your main account/record), a 'Year' field (Number), and an 'Amount' field (Currency/Number).

2
Migrate existing data

Use an Append Query or write a short VBA script to transpose your existing 30 columns of data into the new row-based table structure.

3
Rebuild calculations

Update your queries to calculate values using standard SQL aggregate functions or joins across rows instead of horizontally across 30 columns.

Normalize Your Database Tables
Best Practice: Normalization is the standard for relational databases. It not only fixes the #Error but also drastically improves query performance and scalability.
Free Microsoft Office alternative

Switch to WPS Spreadsheet for Financial Calculations

Recursive 30-year financial models are often much better suited for spreadsheets than relational databases. WPS Spreadsheet handles multi-year financial calculations effortlessly without database query complexity errors. As a free, lightweight, and highly compatible alternative to Microsoft Office, WPS Office offers a seamless environment for your data models.

  1. 1. Export Access Data: Right-click your table in Microsoft Access, select 'Export', and choose 'Excel' to save your data as a spreadsheet file.
  2. 2. Open in WPS Office: Launch WPS Spreadsheet and open the exported file to view your data.
  3. 3. Apply Formulas: Use standard spreadsheet formulas to calculate your 30-year projections instantly by dragging the fill handle.
Handle complex 30-year recursive financial models easily without database limitsFully compatible with Microsoft Excel (.xlsx) formatsFamiliar spreadsheet interface for easier formula management and drag-to-fill featuresFree and lightweight alternative to costly Microsoft Office subscriptions
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Access query return #Error after calculating several columns successfully?

Microsoft Access has a built-in limit on the complexity of nested expressions. When a query calculates a field based on previous calculated fields roughly 25 times in a single row, it overwhelms the query processor's memory stack, resulting in an #Error.

What does a denormalized database design mean?

Denormalization occurs when data that should be stored as separate rows (such as Year 1, Year 2, and Year 3) is instead spread horizontally across multiple columns in a single row. This layout mimics a spreadsheet but violates relational database best practices.

How do I normalize repeating year fields in Access?

To normalize the data, create a new related table containing three columns: a primary/foreign key linking to the main record, a 'Year' column, and a 'Value' column. Each year's financial data is then stored as a separate row rather than an individual column.