logo
search
Others

How to Fix Microsoft Access Error 3021 (No Current Record)

Huma Ashraf ChHuma Ashraf Ch Oct 12, 2026 868 views

Question details

The user needs to handle or resolve Microsoft Access Error 3021, which occurs when VBA code attempts to process a recordset or query that contains no data.

How to Fix Microsoft Access Error 3021 (No Current Record)
Product
Microsoft Access
Device & OS
not provided
Scenario
Executing VBA code that interacts with a recordset or query result, where the data source is unexpectedly empty or the cursor is not pointing to a valid record.
Observed behavior
The application throws 'Error 3021: No Current Record' and abruptly opens the VBA debugger instead of handling the lack of data gracefully.
Before you start

Before modifying your VBA code, ensure you have saved a backup copy of your Access database (.accdb or .mdb) to prevent accidental data loss or code corruption.

Solution 1Recommended

Implement VBA Error Handling with On Error GoTo

Use standard VBA error handling to intercept Error 3021. This prevents the debugger from crashing the application and allows you to display a user-friendly message.

By setting up an error trap, you can instruct your Access application on how to behave when it encounters an empty recordset. Using a Select Case statement allows you to single out Error 3021 while still providing generic alerts for other unexpected issues.

1
Open the VBA Editor

Press Alt + F11 in Microsoft Access to open the Visual Basic for Applications (VBA) editor.

2
Locate the Target Procedure

Find the specific Sub or Function in your modules or form code that is triggering the error.

3
Add the Error Trap

At the very beginning of the procedure, insert the line: 'On Error GoTo ErrorHandler'.

4
Define the Error Handler Logic

At the bottom of the procedure, add the 'ErrorHandler:' label. Below it, write a 'Select Case Err.Number' block. For 'Case 3021', use 'MsgBox "No data is available."'.

5
Insert Exit Logic

Directly above the 'ErrorHandler:' label, add 'Exit Sub' (or 'Exit Function') to ensure normal, error-free execution does not accidentally run the error handling code.

Implement VBA Error Handling with On Error GoTo
Best Practice: Always include an 'Exit Sub' or 'Exit Function' immediately before your error handler label. This ensures your error messages only trigger when an actual error occurs.
Free Microsoft Office alternative

Looking for a lightweight alternative to Microsoft Office?

While Microsoft Access is used for complex databases, most everyday data management, calculation, and reporting tasks can be easily and securely handled using advanced spreadsheets. WPS Office provides a powerful, free alternative to Microsoft Office, featuring full compatibility with Excel, Word, and PowerPoint formats.

  1. 1. Download the Installer: Visit the official WPS website and download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the downloaded installer and follow the on-screen instructions to set up the suite on your computer.
  3. 3. Open Your Data Files: Launch WPS Spreadsheets to seamlessly open, manage, and analyze your existing .xlsx and .csv data files.
Fully compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint (.pptx) formats.Lightweight, fast installation with minimal system resource requirements.Intuitive tabbed interface for managing multiple documents in a single window.Advanced spreadsheet functions and Pivot Tables for robust data analysis and reporting.
microsoft office alternative - wps office

Frequently Asked Questions

What exactly causes Error 3021 in Microsoft Access?

Error 3021 is triggered when your VBA code attempts to read, edit, or delete a record in a recordset that is completely empty, or when the code has moved the cursor past the last record (EOF) or before the first record (BOF).

How do I check if a recordset is empty in VBA?

You can check the BOF (Beginning of File) and EOF (End of File) properties of your recordset. If both `rs.BOF` and `rs.EOF` evaluate to True, it means the recordset contains no data.

Does WPS Office include a database program like Access?

WPS Office includes powerful applications for Word, Excel, and PowerPoint alternatives. While it does not include a direct relational database clone of MS Access, WPS Spreadsheets handles extensive data management, filtering, and pivot tables commonly used in place of basic databases.