Others

Fix #Error When Summing a Calculated Field in Microsoft Access

Tauseeq MagsiTauseeq Magsi Nov 25, 2026 868 views

Question details

The user needs to sum a calculated query field in a Microsoft Access form without displaying #Error.

Fix #Error When Summing a Calculated Query Field in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
A form uses a query field calculated with Val, Eval, Replace, and Left, and a control is intended to show the total.
Observed behavior
The calculated field displays correctly on the form, but a control with the expression =Sum([eLenght]) displays #Error.
Before you start

Open the form in Design View and identify its Record Source and the control containing =Sum([eLenght]). Check whether the detail records are on the main form or a subform, and keep the field spelling eLenght consistent.

Solution 1Recommended

Calculate the field in a query and sum it on the bound form

Use a query as the record source so the form's aggregate control refers to the calculated field.

1
Create the calculation query

In Access, select Create > Query Design and add the source table or query. Add the required fields and define the calculated field as eLenght: Val(Eval(Replace(Left([ElementLenght(ft)],6),"'","*12+")))/12. Save the query with a descriptive name.

2
Test the calculated values

Run the saved query in Datasheet View and check eLenght for every record included in the total. Correct null, malformed, or unexpected source values that cause the expression to fail; do not use Eval with untrusted input.

3
Set the form record source

Open the form that contains the detail records in Design View. In its Property Sheet, select the Data tab and set Record Source to the saved calculation query. Make sure it includes the fields the form needs.

4
Add the total control

Place an unbound text box in that form's header or footer and set its Control Source to =Sum([eLenght]). Give the text box a different name, such as txtTotalLength, so it does not conflict with the field name.

5
Recalculate after changes

In the appropriate form event procedure, such as After Update, use Me.Recalc to refresh calculated controls. Reopen the form and check the total after changing a detail value.

Calculate the field in a query and sum it on the bound form
Check all records: Moving the calculation into a query does not guarantee that every value is valid. A calculation error in any record included in the aggregate can still cause the total to display #Error.
Free Microsoft Office alternative

Work with exported Access data in WPS Spreadsheets

WPS Office is a free, lightweight alternative for everyday document and spreadsheet work. Export Access data to an Excel file, then use the familiar spreadsheet interface to review and total it. WPS does not fix Access form or query errors.

Use spreadsheet formulas to total exported calculation results.Open and edit Microsoft Excel XLSX files for easier migration.Work in a familiar, easy-to-use Office-style interface.Use free spreadsheet tools in a lightweight Office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Sum([eLenght]) show #Error when individual values appear correctly?

The aggregate may encounter an invalid calculation in another record, or eLenght may not be available in the record source of the form containing the total. Run the form's query in Datasheet View and check all included rows and the field name.

Where should I put the Sum control if my detail records are in a subform?

Put an unbound text box with =Sum([eLenght]) in the subform's header or footer. If the main form needs to display the total, reference that text box through the subform control.

What does Me.Recalc do in an Access form?

Me.Recalc recalculates controls on the current form. Add it to an appropriate form event procedure after data changes; it does not reload records from the underlying source.

Can I use WPS Office to repair the Access form?

No. The form and query must be corrected in Microsoft Access. You can export data to an Excel file and open it in WPS Spreadsheets to review or total the exported values.