Fix Access Runtime Error 3061 When Filtering an Unbound Form
Question details
The user needs to filter results for an unbound Access form using an ID selected in a list box.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A list-box selection opens another form and supplies an ID for a query.
- Observed behavior
- The VBA code raises runtime error 3061, reporting that one parameter is missing.
Check the list box's Bound Column property and confirm that its selected value is the ID used by the query. Identify the actual table, ID field, and data type before editing the SQL.
Insert the selected numeric ID into the SQL statement
Use this approach when the form remains unbound and VBA retrieves its data using a numeric ID.
Access may treat a variable name written inside an SQL string as an unresolved parameter rather than the VBA value. Build the SQL using the selected value outside the quoted string. Replace Schedules and SchID in the example with your actual table and field names.
Open the form in Design View, select the control that opens the results form, and use its Property Sheet > Event tab to open the relevant event procedure in the VBA editor.
Before building the query, check Me.lstWO.Value for Null and verify that it is numeric. If no valid ID is selected, display a message and exit the procedure.
For an integer numeric ID, build the query with: sql = "SELECT * FROM Schedules WHERE SchID = " & CLng(Me.lstWO.Value). Then use Set rs = CurrentDb.OpenRecordset(sql), with sql declared as String and rs as DAO.Recordset. Use the returned fields to populate the unbound form's controls.
Add Debug.Print sql before opening the recordset. In the VBA editor, open View > Immediate Window and check the printed SQL for the selected ID and correct table and field names.

Open a bound form with an ID filter
Use a bound form or subform if Access can manage the form's data directly and you do not need to retain the current unbound design.
Work with Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with compatible Office documents. It can help you move everyday document, spreadsheet, and presentation work to one suite, but it does not fix Access VBA errors or replace an Access database.

Frequently Asked Questions
What does Access error 3061 mean?
It means Access expected one or more query parameters but did not receive their values. A misspelled field name or a VBA variable name left inside an SQL string can cause this error.
How can I see the SQL Access is trying to run?
Place Debug.Print sql before the OpenRecordset call, then open View > Immediate Window in the VBA editor to inspect the completed SQL.
Why does the list box return the wrong value?
In the form's Design View, select the list box and check Property Sheet > Data > Bound Column. Its value determines which column is returned by Me.lstWO.Value.
Will DoCmd.OpenForm filter an unbound form's VBA query?
Not automatically. The WhereCondition applies to the opened form's record source; an unbound form that retrieves data in VBA must use the ID in its own query.
What should I do if the selected ID is text?
Use a parameterized QueryDef and assign the selected list-box value to its parameter before opening the recordset. Do not use CLng on a text ID.




