Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO: Storing qry results in Recordset

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi-
I don't know why this code isn't working. I'm doing this in Access and all I'm trying to do is store the results of one of my queries as a Recordset.

Syntactically, I'm not convinced any of this is wrong, but I get a "Too few Parameters. Expected: 1" error on just the last line in this code block:
-------------------------------------------------------
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command

Set conn = CurrentProject.Connection

Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
'In Help it says ADO treats queries as StoredProcedures
cmd.CommandType = adCmdStoredProc
'qryRunRateTotals is the name of the query I'm trying to put in the Recordset
cmd.CommandText = "qryRunRateTotals"

Set rst = New ADODB.Recordset
rst = cmd.Execute
-----------------------------------------------------------

Any advice? I've tried this using the Recordset.Open technique, but that's giving me errors, too.

Many thanks,
-Ed H.
 
Maybe try ?

Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Set conn = CurrentProject.Connection
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
'In Help it says ADO treats queries as StoredProcedures
cmd.CommandType = adCmdStoredProc
'qryRunRateTotals is the name of the query I'm trying to put in the Recordset
cmd.CommandText = "qryRunRateTotals"

Set rst = cmd.Execute()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top