Using Access 2007, I want to call a stored procedure with one input parameter that returns a recordset.
Using ADODB, this is pretty straightforward except for the c
If you already have an Access linked table pointing to the SQL Server database then you can simply use its .Connect
string with a DAO.QueryDef
object to execute the Stored Procedure, as illustrated by the following VBA code:
Sub CallSP()
Dim qdf As DAO.QueryDef, rst As DAO.Recordset
Set qdf = CurrentDb.CreateQueryDef("")
qdf.Connect = CurrentDb.TableDefs("dbo_MyTable").Connect
qdf.SQL = "EXEC dbo.MyStoredProcedure"
qdf.ReturnsRecords = True
Set rst = qdf.OpenRecordset(dbOpenSnapshot)
Debug.Print rst(0).Value
rst.Close
Set rst = Nothing
Set qdf = Nothing
End Sub