Others

Use Stored Procedure Results as a Microsoft Access Form Record Source

John WilsonJohn Wilson Nov 25, 2026 868 views

Question details

Display the results of a stored procedure in a Microsoft Access form.

Use Stored Procedure Results in a Microsoft Access Form
Product
Microsoft Access
Device & OS
not provided
Scenario
A form needs to show records returned by a stored procedure.
Observed behavior
Assigning a recordset object to Me.RecordSource produces an "Invalid use of property" error.
Before you start

Confirm that the stored procedure returns a result set and that you have permission to execute it. Check that the form's bound controls use field names returned by the procedure.

Solution 1Recommended

Assign an ADO Recordset to the Access Form

Use the form's Recordset property when VBA executes the stored procedure and receives an ADO recordset.

RecordSource expects a table name, query name, or SQL statement. An open recordset object must instead be assigned with Set Me.Recordset = rs.

The example uses SQL Server and a parameterless stored procedure. Replace the server, database, and procedure names, and install the specified OLE DB provider if necessary.

1
Prepare the form

Open the form in Design View, open its Property Sheet, and clear the Record Source property if it is not needed. Check that each bound control's Control Source matches a returned field.

2
Add the ADO reference

Open the VBA editor with Alt+F11. Select Tools > References and enable a Microsoft ActiveX Data Objects library.

3
Open and assign the recordset

In the form's VBA module, add the following code. Keep the connection and recordset at module scope so they remain available while the form is open: Private cn As ADODB.Connection Private rs As ADODB.Recordset Private Sub Form_Open(Cancel As Integer) Dim cmd As ADODB.Command Set cn = New ADODB.Connection cn.Open "Provider=MSOLEDBSQL;Data Source=YOUR_SERVER;" & _ "Initial Catalog=YOUR_DATABASE;Integrated Security=SSPI;" Set cmd = New ADODB.Command Set cmd.ActiveConnection = cn cmd.CommandType = adCmdStoredProc cmd.CommandText = "dbo.YourProcedure" Set rs = New ADODB.Recordset rs.CursorLocation = adUseClient rs.Open cmd, , adOpenStatic, adLockReadOnly Set Me.Recordset = rs End Sub

4
Test the form

Save the form, open it in Form View, and confirm that the returned fields and records appear. If the procedure requires parameters, add them to cmd.Parameters before rs.Open.

Assign an ADO Recordset to the Access Form
Read-only results: The example opens a static, read-only recordset. Editing requires an updateable recordset and a source that supports updates.
Free Microsoft Office alternative

Work With Office Files in WPS Office

WPS Office is a free, lightweight alternative for working with documents and spreadsheets in a familiar interface. Its Microsoft Office format support helps you move existing files into your workflow. WPS Office does not run Access forms or fix Access recordset errors.

Review exported table data in WPS SpreadsheetsOpen and edit Microsoft Excel XLSX and Word DOCX filesUse familiar spreadsheet and document editing toolsMove existing Office files into a lightweight workspace
microsoft office alternative - wps office

Frequently Asked Questions

Why does Set Me.RecordSource = rs cause an error?

RecordSource takes a table name, query name, or SQL statement, not a recordset object. Assign an open recordset with Set Me.Recordset = rs instead.

Can I use a DAO recordset with an Access form?

Yes. Open a DAO recordset with CurrentDb.OpenRecordset, then assign it using Set Me.Recordset = rs. A recordset opened with dbOpenSnapshot is read-only.

How can I run a stored procedure without assigning a recordset in VBA?

Create an Access pass-through query containing the procedure's execution command, configure its ODBC Connect Str and Returns Records properties, and set the form's Record Source to the saved query name.

Why are my form controls blank after binding the results?

In Design View, check each control's Control Source against the field names returned by the stored procedure. Also run the procedure or pass-through query separately to confirm that it returns records.