Vba MS Access 2013将存储过程结果连接到组合框记录集
和主题中一样,我需要将存储过程结果连接为记录集。通过一些我发现的例子,我得出了:Vba MS Access 2013将存储过程结果连接到组合框记录集,vba,ms-access,adodb,Vba,Ms Access,Adodb,和主题中一样,我需要将存储过程结果连接为记录集。通过一些我发现的例子,我得出了: 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
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
但是当它击中
Set Me.kod_nadagenta.Recordset = rs
它抛出
“运行时错误“7965”:您输入的对象不是有效的记录集属性。”只需使用以下SQL创建传递查询:
dbo.K_Kod_Agenta_P
现在,只需将组合框建立在传递查询的基础上。你不需要所有的代码