Ashk49
New Member
- Joined
- May 27, 2008
- Messages
- 31
Hi, first, thanks in advance.
Let me try to explain my problem:I made a great query in Microsoft Excel that Imported from SQl. Several fields ,Definitely database is huge and I cant import all data to Excel (Max 65K records). This is what I need ! I made Text box to able to get the DATE entry from customer and my query filter that day and imported to Excel. Data format in the SQL that I have no access to that is like :yyyy-mm-dd h:mm:ss and the Text Box it will be just the DATE :mm-dd/yyyy
.To this point I wrote the code and fix it but when I try to use my parameter in the query instead of Fix Date-Time ,SQL syntax error will pup. my code that involve to this issue is following:
Filter codes marked blue.
Did I made myself clear? Can you help me with this problem?
Thanks a lot!!!
Ashkan
Let me try to explain my problem:I made a great query in Microsoft Excel that Imported from SQl. Several fields ,Definitely database is huge and I cant import all data to Excel (Max 65K records). This is what I need ! I made Text box to able to get the DATE entry from customer and my query filter that day and imported to Excel. Data format in the SQL that I have no access to that is like :yyyy-mm-dd h:mm:ss and the Text Box it will be just the DATE :mm-dd/yyyy
.To this point I wrote the code and fix it but when I try to use my parameter in the query instead of Fix Date-Time ,SQL syntax error will pup. my code that involve to this issue is following:
Rich (BB code):
Dim Filter_Date
Dim Begin_Of_Day
Dim End_Of_Day
Filter_Date = Application.Sheets("ATL").TextBox1.Value
' test
' Range("P11").Select
' ActiveCell.Value = Filter_Date
' Selection.Copy
Sheets("DATA2").Select
Range("J2").Select
Selection.NumberFormat = "yyyy-mm-dd h:mm:ss.000"
ActiveCell.Value = Filter_Date
Selection.NumberFormat = "General"
Selection.Copy
Range("J3:J4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.NumberFormat = "General"
'made Date in general format ,ready to add Time to the number and reconvert it
'-------------start time -----------------
Range("J3").Select
Begin_Of_Day = ActiveCell.Value + 0.00001
Range("J3").Value = Begin_Of_Day
Selection.NumberFormat = "yyyy-mm-dd h:mm:ss.000"
Begin_Of_Day = Range("J3").Value
Range("J5").Value = Begin_Of_Day
'--------------End time -------------------
Range("J4").Select
End_Of_Day = ActiveCell.Value + 0.99999
Range("J4").Value = End_Of_Day
Selection.NumberFormat = "yyyy-mm-dd h:mm:ss.000"
End_Of_Day = Range("J4").Value.........
...........
...............
.................
...................
....................
.CommandText = Array( _
"SELECT ProductLine.LineID, LineRun.RunID, Product.ProductID, Material.MaterialName, ProductLine.UnitsPerMin, RunLineDeviceRecipe.UnitWt_SET, LineRun.ActualUnits, LineRun.ActualWt, LineRun.DateOpened, LineRun.DateClosed," _
, _
"ProductLine.ProductID, LineDeviceStateLog.DTReasonEX, Product.ProductID" & Chr(13) & "" & Chr(10) & "FROM LineRun LineRun, Material Material, Product Product,Pr" _
, _
"oductLine ProductLine, RunLineDeviceRecipe RunLineDeviceRecipe ,LineDeviceStateLog LineDeviceStateLog " & Chr(13) & "" & Chr(10) & "WHERE Material.Material" _
, _
"ID = Product.MaterialID AND ProductLine.ProductID = Product.ProductID AND RunLineDeviceRecipe.LineID = ProductLine.LineID AND RunLineDeviceRecipe.RunID = LineRun.RunID AND ProductLine.LineID = LineRun.LineID AND LineDeviceS" _
, _
"tateLog.LineID = LineRun.LineID AND LineDeviceStateLog.DateClosed = LineRun.DateClosed AND LineDeviceStateLog.DateOpened = LineRun.DateOpened AND" _
, _
"((LineRun.DateOpened>={ts (Begin_Of_Day) } And LineRun.DateOpened<={ts ( End_Of_Day) }))" & Chr(13) & "" & Chr(10) & "ORDER BY ProductL" _
, _
"ine.LineID, Product.ProductID, LineRun.RunID" _
)
Did I made myself clear? Can you help me with this problem?
Thanks a lot!!!
Ashkan