Script for Excel VBA to use a Stored Procedure with an Input Parameter
Posted on 2010-09-20
Pretty much a rookie at this...
I have a store procedure "GlDrillDown", which has a parameter called @EnterYear...
I am trying to create an input from the user that will allow a year to be entered and have the data filtered out according to this input..
Here is my Code
.. Dont laugh :(
Private Sub CommandButton1_Click()
' Declare the QueryTable object
Dim qt As QueryTable
' Set up the SQL Statement
sqlstring = "Execute GLDrillDown"
' Set up the connection string, reference an ODBC connection
' There are several ways to do this
' Leave the name and password blank for NT authentication
connstring = _
' Now implement the connection, run the query, and add
' the results to the spreadsheet starting at row A1
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=sqlstring)