I have some code using DAO that I have been testing to collect parameters and return a recordset and this works fine. However I would like to do this in ADO if possible. Can anyone help with a similar Function in ADO?
Dim qdf As DAO.QueryDef, rst As DAO.Recordset
Dim IdValueToProcess As Long
IdValueToProcess = 12300 ' test data
Set qdf = CurrentDb.CreateQueryDef("")
qdf.ReturnsRecords = True
qdf.Connect = "ODBC;DSN=?????;Trusted_Connection=Yes;"
qdf.SQL = "EXEC dbo.Martin " & IdValueToProcess
Set rst = qdf.OpenRecordset(dbOpenSnapshot)
Debug.Print rst!Name1 ' just to make sure we got a result
Debug.Print rst!Surname ' just to make sure we got a result
Set Forms!Form1.Recordset = rst
Set rst = Nothing
Set qdf = Nothing