I recorded a macro of the creation of a pivot table. The results are understandable except for the Array that is used to describe the SQL needed for the query. Here's what I get:
I apologize for the length of this, but if you just look over it you'll perhaps see what I mean.
Excel automatically trimmed formatted the array in the most odd way. I cannot for the life of me figure out why there are commas where they are. For example, the word "FROM" is split up into "F", "ROM. If I attempt to combine the F and the ROM into one word, thus eliminating two double quotes and the comma, the code craps out with a "type mismatch" error. If I leave it the way it is it works just fine.
I'd REALLY like to format the string so that it'll be more easily manaed when I start creating more pivot tables and such.
PLEASE HELP!! THANK YOU!! Onwards,
Q-
Code:
strSQL = Array("SELECT Count(UPI_Events.Index), UPI_Events.StartTime, UPI_Events.TagIndex, UPI_Events.TypeIndex, UPI_Tags.UnitIndex, UPI_Tags.Tag, UPI_Tags.Description, UPI_Units.SectionIndex, UPI_Sections.Section" & vbCrLf & _
"F", "ROM `c:\UPI\UPI_DATA_UNIT2`.UPI_Events UPI_Events, `c:\UPI\UPI_DATA_UNIT2`.UPI_Sections UPI_Sections, `c:\UPI\UPI_DATA_UNIT2`.UPI_Tags UPI_Tags, `c:\UPI\UPI_DATA_UNIT2`.UPI_Units UPI_Units" & vbCrLf & "WHERE UPI_" _
, "Events.TagIndex = UPI_Tags.TagIndex AND UPI_Sections.SectionIndex = UPI_Units.SectionIndex AND UPI_Tags.UnitIndex = UPI_Units.UnitIndex" & vbCrLf & "GROUP BY UPI_Events.StartTime, UPI_Events.TagIndex, UPI_Events." _
, "TypeIndex, UPI_Tags.UnitIndex, UPI_Tags.Tag, UPI_Tags.Description, UPI_Units.SectionIndex, UPI_Sections.Section" & vbCrLf & "HAVING (UPI_Events.TypeIndex=1) AND (UPI_Events.StartTime>={ts '2003-02-01 00:00:00'}) " _
, "OR (UPI_Events.TypeIndex=2) AND (UPI_Events.StartTime>={ts '2003-02-01 00:00:00'})OR (UPI_Events.TypeIndex=3)AND (UPI_Events.StartTime>={ts '2003-02-01 00:00:00'})")
I apologize for the length of this, but if you just look over it you'll perhaps see what I mean.
Excel automatically trimmed formatted the array in the most odd way. I cannot for the life of me figure out why there are commas where they are. For example, the word "FROM" is split up into "F", "ROM. If I attempt to combine the F and the ROM into one word, thus eliminating two double quotes and the comma, the code craps out with a "type mismatch" error. If I leave it the way it is it works just fine.
I'd REALLY like to format the string so that it'll be more easily manaed when I start creating more pivot tables and such.
PLEASE HELP!! THANK YOU!! Onwards,
Q-