I created a form in excel with button and listbox. Once you click a button, I have the below code which connects to a SQL database and returns values in a excel list box with the execution of a SQL statement . what i would like to do is instead of using the SQL i want to run a stored procedure instead, i would replace the SQL with SP_GET_INFO . here is the current code. Any help would be appreciated
Private Sub cmbList_Click()
Dim conn As New ADODB.Connection
Dim myRecSet As New ADODB.Recordset
Dim SQL As String
With conn
.Provider = "SQLOLEDB"
.Properties("Prompt") = adPromptAlways
.ConnectionString = "Data Source=someserver\SQLEXPRESS; " & _
"Initial Catalog=some catalog;"
On Error Resume Next
.Open
If Err.Number <> 0 Then
MsgBox ("You have elected to cancel this request"), vbOKOnly
Exit Sub
End If
On Error GoTo 0
End With
SQL = "select TR_name, TR_Id, TR_Date from TBL_Employee WHERE TR_Status = '" & frmOrg_ID.cmbSelection & "' and TR_DRE > '2012-04-01' order by TR_Org_Id desc"
myRecSet.Open SQL, conn
If Not myRecSet.EOF Then
Me.ListBox1.Column = myRecSet.GetRows
End If
End Sub
Bookmarks