Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting which date to import from a query.

Status
Not open for further replies.

Blyss

Technical User
Jul 5, 2004
15
US
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?
 
Have you tried to make this query parametised with MS-Query ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top