Skip to content
Auscultby NBIT
EN
Free diagnostic

Access error reference

Access runtime error 3021: “No current record.”

The application has worked for years, then one day a form or button stops on “No current record”. Nothing changed in the code: the data did — an empty table, a filter that finds nothing.

The message

Run-time error '3021': No current record.

English Access

On a French Access: « Aucun enregistrement en cours. »

Where it shows up

In code that walks a recordset (rs.MoveFirst, rs.Edit, rs!Field), uses a form's bookmark (Me.Bookmark, RecordsetClone), or when a form reads its current record as soon as it loads.

Common causes

  • an empty recordset: the query returns nothing and the code reads the first row anyway;
  • moving past the end: after MoveNext on the last row, the code reads another field;
  • a form with no record: empty table, filter with no result, or a form opened for data entry;
  • a row deleted by another user between reading it and editing it.

How to reproduce and check it

  1. Reproduce with a filter that finds nothing, or on a copy where the table involved is empty.
  2. Put a breakpoint on the highlighted line and look at rs.EOF and rs.BOF: if both are True, the recordset is empty.

How to fix it

Test before reading: If Not (rs.BOF And rs.EOF) Then …, or If rs.RecordCount > 0. In a loop, Do While Not rs.EOF … rs.MoveNext … Loop. On a form, check Me.Recordset.RecordCount or Me.NewRecord before using the current record.

What Auscult reports

This is the textbook conditional fault: it is real, but only when a condition is met. When the error comes from there being no record in the analysed copy, the diagnostic does not count it as an ordinary fault: it reports it as “fails if there is no record to show” or “fails if … is empty”, naming the source, and suggests handling that case. On your real data, it will happen as soon as the condition is met.

Measured on our test corpus: this message was recorded while analysing 27 of 965 applications.

The Access error reference, code by code

Frequently asked questions

Why does it appear in an application that used to work?

Because it depends on the data: a table cleared at the start of the year, a customer with no orders, a filter that finds nothing. The code had simply never met that case.

Where are the other errors in your application hiding?

The diagnostic runs on your computer, on a copy of the application, without sending the data in your tables. The health grade and the summary are free.