Reputation: 21
AS in topic, I need to connect stored procedure results as recordset. Using some examples I found I came up with:
Dim cn As New ADODB.Connection
cn = GetConnection()
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With cmd
.ActiveConnection = GetConnection()
.CommandText = "dbo.K_Kod_Agenta_P"
.CommandType = adCmdStoredProc
.Parameters.Refresh
End With
With rs
.ActiveConnection = GetConnection()
.CursorType = adOpenForwardOnly
.CursorLocation = adUseServer
End With
Set rs = cmd.Execute
Set Me.kod_nadagenta.Recordset = rs
rs.Close
cn.Close
But when it hits
Set Me.kod_nadagenta.Recordset = rs
it throws
"Run-time error '7965': The object you entered is not a valid Recordset property."
Upvotes: 1
Views: 470
Reputation: 49009
Just create a pass-through query with the following SQL:
dbo.K_Kod_Agenta_P
Now simply base the combo box on that pass-through query. You don’t need all that code.
Upvotes: 1