The following code run a stored procedure based on a combobox that is selected in a form. I need to display the results in a form in Access. Here is the code:
Dim Cmd1 As ADODB.Command
Dim lngRecordsAffected As Long
Dim rs1 As ADODB.Recordset
Dim intRecordCount As Integer
'-----
Dim cnnTemp As ADODB.Connection
Set cnnTemp = New ADODB.Connection
cnnTemp.ConnectionString = "DRIVER=SQL Server;SERVER=****;" & _
"Trusted_Connection=No;UID=****;PWD=****;" & _
"Initial Catalog=IKB_QA;"
'Open Connection
cnnTemp.Open
Set Cmd1 = New ADODB.Command
Cmd1.ActiveConnection = cnnTemp
'---
With Cmd1
Dim localv As Integer
localv = [Forms]![start]![Selection]![cat_code]
.CommandText = "dbo.ix_spc_planogram_match"
.CommandType = adCmdStoredProc
.Parameters.Refresh
.Parameters("@catcode").Value = localv
Set rs1.Open = Cmd1.Execute(localv)
End With
End Sub