loading a subform with recordset in vba code

C

Chris

Hi,

I have a sub procedure that accepts parameters.
Everything works until the line where I try to bind the recordset to
the subreport in the form.

here is my code:

Dim Cmd As New ADODB.Command
Dim rs As New ADODB.Recordset

' Define a command object for a stored procedure.
Cmd.ActiveConnection = Application.CurrentProject.BaseConnectionString
Cmd.CommandText = storeprocedurename
Cmd.CommandType = adCmdStoredProc
Cmd.CommandTimeout = 15
Cmd.Parameters(1) = searchvalue

' Create a recordset by executing the command.
Set rs = Cmd.Execute

'Me.subReportMain.Form.Recordset = rs
'Me.subReportMain.Form.Recordsource = rs

I've tried all kinds of combinations but I can't get it to bind without
error messages.

Also I think that after I bind I may still need to provide a line of code to
update the form to show the records in the form.

What might that be, if that is the case?

thanks

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top