How to Fix Microsoft Access Error 3021 (No Current Record)
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.

- 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 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.
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.
Press Alt + F11 in Microsoft Access to open the Visual Basic for Applications (VBA) editor.
Find the specific Sub or Function in your modules or form code that is triggering the error.
At the very beginning of the procedure, insert the line: 'On Error GoTo ErrorHandler'.
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."'.
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.

Prevent the Error by Checking EOF and BOF
Instead of waiting for an error to occur, proactively check if the recordset is empty before attempting to read or manipulate records.
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. Download the Installer: Visit the official WPS website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the downloaded installer and follow the on-screen instructions to set up the suite on your computer.
- 3. Open Your Data Files: Launch WPS Spreadsheets to seamlessly open, manage, and analyze your existing .xlsx and .csv data files.

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.




