![]() |
query table macro
In the following, how do i change the date to read from a
cell.(uvwNFL_BatchReport.Start={ts '2006-05-10 00:00:00'" , "})") Any assistance will be welcome Thanks Full Code With Selection.QueryTable .Connection = _ "ODBC;DRIVER=SQL Server;SERVER=citp2b;UID=citect;PWD=citect;APP=Mic rosoft Office XP;WSID=CH-L-H8LP51S;DATABASE=NFL" .CommandText = Array( _ "SELECT uvwNFL_BatchReport.BatchLogID, uvwNFL_BatchReport.Pasteuriser, uvwNFL_BatchReport.Start, uvwNFL_BatchReport.Finish, uvwNFL_BatchReport.Destination, uvwNFL_BatchReport.TankProduct, uvwNFL_BatchR" _ , _ "eport.BatchProduct, uvwNFL_BatchReport.BatchVolumeReq, uvwNFL_BatchReport.BatchVolumeDel" & Chr(13) & "" & Chr(10) & "FROM NFL.dbo.uvwNFL_BatchReport uvwNFL_BatchReport" & Chr(13) & "" & Chr(10) & "WHERE (uvwNFL_BatchReport.Start={ts '2006-05-10 00:00:00'" _ , "})") .Refresh BackgroundQuery:=False End With |
query table macro
Something like:
Const SINGLEQUOTE As Long=39 "WHERE (uvwNFL_BatchReport.Start={ts " & Chr(SINGLEQUOTE) & Range("A1").Text & Chr(SINGLEQUOTE) & "})" Depending on the .Value/Text in the cell, you may need to use Format( ), to get the entry in the expected format. "WHERE (uvwNFL_BatchReport.Start={ts " & Chr(39) & Format(Range("A1").Text, "yyyy-mm-dd hh:mm:ss") & Chr(39) & "})" NickHK "aquamatt" wrote in message ... In the following, how do i change the date to read from a cell.(uvwNFL_BatchReport.Start={ts '2006-05-10 00:00:00'" , "})") Any assistance will be welcome Thanks Full Code With Selection.QueryTable .Connection = _ "ODBC;DRIVER=SQL Server;SERVER=citp2b;UID=citect;PWD=citect;APP=Mic rosoft Office XP;WSID=CH-L-H8LP51S;DATABASE=NFL" .CommandText = Array( _ "SELECT uvwNFL_BatchReport.BatchLogID, uvwNFL_BatchReport.Pasteuriser, uvwNFL_BatchReport.Start, uvwNFL_BatchReport.Finish, uvwNFL_BatchReport.Destination, uvwNFL_BatchReport.TankProduct, uvwNFL_BatchR" _ , _ "eport.BatchProduct, uvwNFL_BatchReport.BatchVolumeReq, uvwNFL_BatchReport.BatchVolumeDel" & Chr(13) & "" & Chr(10) & "FROM NFL.dbo.uvwNFL_BatchReport uvwNFL_BatchReport" & Chr(13) & "" & Chr(10) & "WHERE (uvwNFL_BatchReport.Start={ts '2006-05-10 00:00:00'" _ , "})") .Refresh BackgroundQuery:=False End With |
All times are GMT +1. The time now is 07:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com