how to pass a list of SQL Server tables into List Box in Excel and use it -
i have made report file in excel analysts check data every morning. how looks now: 
where button's script following:
sub button6_click() dim qt querytable sqlstring1 = "select * dbo.reportunits order productid, countrycodeid" activesheet.querytables.add(connection:=getconnectionstr2, destination:=range("a3"), sql:=sqlstring1) end end sub private function getconnectionstr2() 'driver={sql server}; getconnectionstr2 = "odbc;driver={sql server};" & _ "database=em_countryconsumer;" & _ "server=555.555.55.15;" & _ "uid=user;" & _ "pwd=password;" end function what have additional list box list of report tables in sql server database. in example dbo.reportunits table, there more report tables , creating automatically every day.
to give analysts chance choose table name. , show data pressing refresh button.
is possible? thank in advance!
- create reference "microsoft activex data objects xxx library"
- use
adodb.connection,adodb.recordsetobjects create connection , define query oninformation_schema.tables - read column
table_nameitems of (activex) listbox placed in sheet or listbox of vba form using.movenext,eof
Comments
Post a Comment