Others

Display 0 in an Access Text Box When a Continuous Form Has No Records

Adam DavisAdam Davis Nov 13, 2026 869 views

Question details

The user needs an Access continuous-form text box to display 0 when there are no records and remain updated after a search dialog requeries the form.

Display 0 in an Access Text Box When a Continuous Form Has No Records
Product
Microsoft Access
Device & OS
not provided
Scenario
A search dialog changes the criteria and requeries an already-open continuous form.
Observed behavior
The text box becomes blank when the form has no records or after the search dialog requeries it.
Before you start

Open the continuous form in Design View and check the text box's Name, Control Source, and section. Put a summary text box in the Form Header or Form Footer rather than the Detail section, which may have no visible row when the form is empty.

Solution 1Recommended

Update an unbound record-count text box on Current and after Requery

Use this approach when the text box must reliably show 0 for an empty recordset and update after an external search dialog requeries the form.

1
Create an unbound summary text box

Open the continuous form in Design View. Enable the Form Header/Footer sections if needed, place a text box in one of those sections, and set its Name to txtRecordCount. Leave its Control Source blank.

2
Add a reusable update procedure

Open the form's VBA module and add this procedure: Public Sub UpdateRecordCount() Dim rs As DAO.Recordset Set rs = Me.RecordsetClone If rs.BOF And rs.EOF Then Me!txtRecordCount = 0 Else rs.MoveLast Me!txtRecordCount = rs.RecordCount End If rs.Close Set rs = Nothing End Sub This counts the records in the form's current recordset without changing the selected record on the form.

3
Call the procedure from On Current

In the form's Property Sheet, open the Event tab, set On Current to [Event Procedure], and click the ellipsis button. Add UpdateRecordCount to the existing Form_Current procedure: Private Sub Form_Current() UpdateRecordCount End Sub

4
Update again after the search dialog requeries the form

In the search dialog's button-click procedure, call the update immediately after requerying the continuous form: Forms("frmResults").Requery Forms("frmResults").UpdateRecordCount Replace frmResults with the actual name of your open continuous form. Apply any filter or query criteria before these calls.

Update an unbound record-count text box on Current and after Requery
An empty Detail section cannot display a summary control: If an empty form does not show a new-record row, a text box in the Detail section has no row in which to appear. Use a Form Header or Form Footer control for an always-visible summary.
Free Microsoft Office alternative

Use WPS Spreadsheets for exported Access results and reports

WPS Office is a free, lightweight alternative for working with Access results exported to Excel. Its familiar spreadsheet interface and Microsoft Office format compatibility make moving exported tables into spreadsheet reports straightforward. It does not run Access forms, VBA form events, or Access database files.

Analyze exported Access search results in WPS Spreadsheets.Open and edit Microsoft Excel .xlsx and .xls files.Use a familiar spreadsheet interface for tables, formulas, and summary reports.Get a free, lightweight office suite for everyday document and spreadsheet work.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the text box disappear when my continuous form has no records?

A control in the Detail section appears within a record row. If the form has no records and does not display a new-record row, there is no Detail row to show it. In Design View, move the summary text box to the Form Header or Form Footer.

Where should I put the code if a search dialog requeries an already-open form?

Add the update call immediately after the search dialog's Forms("frmResults").Requery statement. Keep the same update call in the continuous form's On Current event so both normal navigation and externally triggered requeries are covered.

Will setting Default Value to 0 fix a calculated text box?

Not reliably. Default Value does not act as a fallback for a calculated Control Source. For explicit control over empty results, leave Control Source blank and assign 0 in VBA after checking the form's RecordsetClone.

Should I use Refresh, Requery, or Recalc after changing search criteria?

Use Requery when criteria changes require the form to retrieve a new set of records. Use Recalc afterward to reevaluate calculated controls, or call your unbound-control update procedure. Refresh alone does not rerun the form's underlying query to retrieve a new result set.

Can enabling Navigation Buttons make my custom text box show 0?

You can enable the built-in navigation area through Design View > Property Sheet > Format > Navigation Buttons > Yes. However, this does not populate a custom text box or make a Detail-section control visible without a row. Use a header or footer count control for the custom display.