Fix Microsoft Access Error 3061 When Opening a Parameter Query Recordset
Question details
The user needs to open a DAO recordset from a saved Microsoft Access parameter query that references form controls without receiving Run-Time Error 3061.

- Product
- Microsoft Access with DAO and VBA
- Device & OS
- not provided
- Scenario
- A VBA procedure opens the saved query qryClassList, whose parameters refer to controls on an Access form.
- Observed behavior
- Opening the recordset fails with Run-Time Error 3061 because the query parameters have not been supplied. The follow-up code also reports an object-related error when the database object is used before initialization.
Confirm that qryClassList exists and that the form referenced by its parameters is open with the required control values. In the VBA editor, check Tools > References if DAO types are not recognized; the appropriate Access database engine or DAO library must be available.
Initialize the DAO database and evaluate parameters before opening the recordset
Use this method when a saved query references open Access form controls and DAO reports Error 3061 because their values have not been resolved.
DAO does not automatically resolve form-control references when opening a saved query as a recordset. Retrieve the QueryDef, assign its parameter values, and then call OpenRecordset.
In the Access Navigation Pane, right-click qryClassList and select Design View. Check references such as [Forms]![YourForm]![YourControl], verify the form and control names, and open the referenced form before running the VBA procedure.
Press Alt+F11 to open the VBA editor. In the procedure that needs the recordset, replace the recordset-opening code with the following, keeping any recordset-processing code after the final line: Dim dbs As DAO.Database Dim qdf As DAO.QueryDef Dim prm As DAO.Parameter Dim ValList As DAO.Recordset Set dbs = CurrentDb Set qdf = dbs.QueryDefs("qryClassList") For Each prm In qdf.Parameters prm.Value = Eval(prm.Name) Next prm Set ValList = qdf.OpenRecordset
Return to Access, enter the required values in the referenced form controls, and run the button or procedure that opens the recordset. After processing the results, close ValList and release the object variables when they are no longer needed.

Check uninitialized objects and unexpected query parameters
Use these checks if the revised procedure reports an object-related error or still cannot resolve all parameters.
Use WPS Office for Documents and Spreadsheets Alongside Access
WPS Office is a free, lightweight alternative for everyday Office documents, spreadsheets, and presentations, with a familiar interface and Microsoft Office format compatibility for easy migration. It does not repair Access DAO errors or replace Access databases, but WPS Spreadsheet can work with query results exported to Excel or CSV.

Frequently Asked Questions
Why does the query work in Access but fail when VBA opens a recordset?
Access can resolve form references when you open a query interactively, but DAO requires you to supply the QueryDef parameter values before calling OpenRecordset. Retrieve the saved query through dbs.QueryDefs("qryClassList"), assign its parameters, and then open the recordset.
Does the form need to be open when I use Eval?
Yes, if a parameter refers to a form control. Open the referenced form and populate its controls before running the procedure. If the form is closed or a control name is incorrect, Eval cannot resolve that reference.
Why does the code fail at dbs.QueryDefs after I declare dbs?
Dim dbs As DAO.Database only declares the variable. Add Set dbs = CurrentDb before Set qdf = dbs.QueryDefs("qryClassList") so the variable points to the current database.
Can a misspelled field name cause Error 3061?
Yes. Access may treat an unrecognized identifier as a parameter. Open the query in Design View and verify field names and aliases. Printing prm.Name in the VBA Immediate window helps identify unexpected parameters.
Can WPS Office run this Access QueryDef code?
No. This solution requires Microsoft Access and DAO. To use the query results in WPS Spreadsheet, first run the query successfully in Access, then use External Data > Export to export the results to Excel or a text file such as CSV.




