Fix an Overflow Error in a Nested Microsoft Access Query
Question details
Identify and fix a calculation that causes an overflow when a Microsoft Access query is used inside another query.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A user references a calculated field from one Access query in a second query.
- Observed behavior
- The source query works independently, but the nested query produces an Overflow error or fails to display the calculated cost.
Open both the source query and the query that references it in Access. Note the calculated field name, its expression, and the data types of the fields used in the calculation.
Isolate the expression that causes the overflow
Test the calculated field in smaller parts to find which operation fails when the query is nested.
In the Navigation Pane, right-click the source query and select Design View. Find the calculated field containing the nested IIf expression.
In the calculated field's Field row, replace the full expression temporarily with one IIf expression or a single calculation. Select Run to check the result.
Return to Design View, add the next part of the expression, and select Run again. Repeat until you identify the part that triggers the error.
Inspect the failing operation for values outside the result type's range, Null values, and zero divisors. Where appropriate, convert operands before arithmetic with a suitable function such as CDbl or CCur, then run both queries again.

Move reusable calculations into a VBA function
Use a small user-defined function when a long or repeated business calculation is difficult to test and maintain.
Work with exported query results in WPS Spreadsheets
WPS Office is a free, lightweight alternative for everyday office work, with a familiar interface and Microsoft Office format compatibility for easier migration. Export Access query results to Excel to review them in WPS Spreadsheets; WPS does not fix or run Access queries.

Frequently Asked Questions
Why does the source query work but the nested query overflow?
The outer query may evaluate or combine the calculated expression differently or process values that expose an overflow. Open both queries in Design View and test the calculation in smaller parts to isolate the cause.
Can IIf cause an error in a branch that is not selected?
Yes. Access evaluates both the true and false parts of IIf. Check both branches for invalid conversions, zero divisors, and calculations that exceed the numeric type's range.
How can I check the data types used by the calculation?
Open the source tables in Design View and inspect the Data Type and Field Size properties of the fields used in the query. Also review conversions and arithmetic in the query's calculated Field row.
Can WPS Office repair an Access query?
No. Troubleshoot the query in Microsoft Access. You can export query results to an Excel file and open that file in WPS Spreadsheets for review.




