- Joined
- Sep 8, 2014
- Messages
- 1
- Reaction score
- 0
I've begun setting up a module for a click event. I'm wanting to click a button and have it export the results of a stored procedure called "usp_IssueTrackingGetPastDueIssues". I am having a hard time finding info on how to code this I am fairly new to vba. Any help would be greatly appreciated below is the module I have begun setting up.
Private Sub cmdExcel_Click()
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSql As String
Dim xlApp As New Excel.Application
Dim wbk As Excel.Workbook
Dim wksht As Excel.Worksheet
Set db = New ADODB.Connection
db.ConnectionString = "PROVIDER=SQLNCLI10;SERVER=SVBKSA69901M2W\IKM_QA;DATABASE=RiskControl;TRUSTED_CONNECTION=yes;"
db.Open
sSql = "usp_IssueTrackingGetPastDueIssues"
db.Execute sSql
db.Close
Set db = Nothing
Exit Sub
CleanExit:
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
Private Sub cmdExcel_Click()
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSql As String
Dim xlApp As New Excel.Application
Dim wbk As Excel.Workbook
Dim wksht As Excel.Worksheet
Set db = New ADODB.Connection
db.ConnectionString = "PROVIDER=SQLNCLI10;SERVER=SVBKSA69901M2W\IKM_QA;DATABASE=RiskControl;TRUSTED_CONNECTION=yes;"
db.Open
sSql = "usp_IssueTrackingGetPastDueIssues"
db.Execute sSql
db.Close
Set db = Nothing
Exit Sub
CleanExit:
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub