Count Records in a Microsoft Access DAO Recordset
Question details
Determine whether an Access table contains records before processing them with DAO.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A VBA procedure needs to check a local temporary table or a linked table before processing its records.
- Observed behavior
- The user wants to identify an empty table and choose whether to open or process a recordset.
Confirm whether the table is local or linked in the Access Navigation Pane, and replace the example table name with your own. Open the VBA editor with Alt+F11 and check Tools > References for a Microsoft Office Access database engine or DAO library if DAO types are not recognized.
Check a Local Table with DAO TableDef.RecordCount
Use this approach to check a local table before opening its recordset.
In Access, press Alt+F11 and open the module containing your table-processing procedure.
Add this code to your procedure, replacing t_ExcelExport_auto with your local table name: Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb If db.TableDefs("t_ExcelExport_auto").RecordCount = 0 Then ' Handle the empty table Else Set rst = db.OpenRecordset("t_ExcelExport_auto") ' Process the recordset, then close it rst.Close End If
Run the procedure from Access or press F5 in the VBA editor, and verify that the appropriate empty-table or processing branch runs.

Check a Linked Table by Opening a DAO Recordset
Use a recordset to test whether a linked table is empty, or move to the last record when you need the full count.
Use DCount Before Opening the Recordset
Use DCount when you want a domain count or need to count only records matching a criterion.
Work with Exported Access Data in WPS Office
WPS Office is a free, lightweight, easy-to-use alternative for everyday Office work. Export Access data to an Excel workbook, then use WPS Spreadsheets' familiar interface to review it; compatible Office formats make migration straightforward.

Frequently Asked Questions
How can I tell whether an Access recordset is empty?
After opening the recordset with CurrentDb.OpenRecordset, check rst.EOF. If it is True immediately after opening, the recordset contains no records.
Why is my DAO RecordCount lower than the total number of rows?
For a dynaset or snapshot, RecordCount reflects records accessed so far. If the recordset is nonempty and supports moving backward, call rst.MoveLast before reading rst.RecordCount.
Can I use TableDef.RecordCount for a linked table?
Do not rely on TableDef.RecordCount for a linked table. Open a DAO recordset and check EOF, or use DCount with the linked table name.
How do I count only records that meet a condition?
Use the criteria argument of DCount, for example DCount("*", "t_ExcelExport_auto", "[Status] = 'Ready'"). The criteria syntax is similar to a SQL WHERE clause without the word WHERE.




