Hi,
I'm importing data and running a query before transferring it to excel - this is all done in macros . One of the criteria is that it has to be on a certain date. However, I want, say, a inputbox to pop up and ask for which date it should limit the results by before it imports it to excel. I was wondering if anyone could help me out with a code or something. the code i've got so far is:
With Selection.QueryTable
.Connection = _
"ODBC;DRIVER=SQL Server;SERVER=server123;UID=ac123;PWD=2468;APP=Microsoft® Query;WSID=A2854A"
.Sql = Array( _
"SELECT vw_tab.AccountNumber, vw_tab.Date, vw_tab.CUS, vw_GACT.DescriptionLine1, vw_tab.Indicator, vw_tab.Quantity, vw_tab.ReferenceNumber, vw_tab.DateOfData" & Chr(13) & "" & Chr(10) & "FROM ac123.d" _
, _
"bo.vw_tab vw_tab" & Chr(13) & "" & Chr(10) & "WHERE (vw_tab.Type='s') AND (vw_tab.TradeDate={ts '2004-07-11 00:00:00'}) AND (vw_tab.indicator='l'})")
Could nayone help me out?
I'm importing data and running a query before transferring it to excel - this is all done in macros . One of the criteria is that it has to be on a certain date. However, I want, say, a inputbox to pop up and ask for which date it should limit the results by before it imports it to excel. I was wondering if anyone could help me out with a code or something. the code i've got so far is:
With Selection.QueryTable
.Connection = _
"ODBC;DRIVER=SQL Server;SERVER=server123;UID=ac123;PWD=2468;APP=Microsoft® Query;WSID=A2854A"
.Sql = Array( _
"SELECT vw_tab.AccountNumber, vw_tab.Date, vw_tab.CUS, vw_GACT.DescriptionLine1, vw_tab.Indicator, vw_tab.Quantity, vw_tab.ReferenceNumber, vw_tab.DateOfData" & Chr(13) & "" & Chr(10) & "FROM ac123.d" _
, _
"bo.vw_tab vw_tab" & Chr(13) & "" & Chr(10) & "WHERE (vw_tab.Type='s') AND (vw_tab.TradeDate={ts '2004-07-11 00:00:00'}) AND (vw_tab.indicator='l'})")
Could nayone help me out?