ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   some code help please (https://www.excelbanter.com/excel-programming/340169-some-code-help-please.html)

sd

some code help please
 
I'm new to this so please be easy on me. I have a macro the returns
data from a query. I want to change the criteria of this query by
entering new dates into a text box. I have not yet added the text boxes
but I have changed the data in the code. (Remember baby steps)

When I run the macro I get a error. Bad character found in date string.

Please help me fix this.


Dim EDate As Variant, EndDate As String
EDate = "9-sep-2005 07:00:00"
EndDate = EDate

Sheets("sheet3").Select
Range("D6").Select
ActiveSheet.PivotTableWizard SourceType:=xlExternal,
SourceData:=Array( _
"SELECT ss_hist_base.mach_name, ss_hist_base.tool,
ss_hist_base.shift_id, Sum(ss_hist_base.total_down_time)" & Chr(13) &
"" & Chr(10) & "FROM plantstar.ss_hist_base ss_hist_base" & Chr(13) &
"" & Chr(10) & "WHERE (ss_hist_base.start_time='29-aug-2005 07:00" _
, _
":00' And ss_hist_base.start_time<'EndDate &"" ' )" & Chr(13) &
"" & Chr(10) & "GROUP BY ss_hist_base.mach_name, ss_hist_base.tool,
ss_hist_base.shift_id" _
), Connection:= _

"ODBC;DSN=OPENINGRES;SERVER=PLANTSTAR;DATABASE=foc us2000;SERVERTYPE=INGRES"
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields
RowFields:="mach_name", _
ColumnFields:="tool"
Sheets("report").Select
End Sub



All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com