Hi everybody:
This makes NO sense to me! I’m using an ODBC connection to my Access .mdb tables to get the data to create a pivottable report using VBA. I have successfully created the command text for my pivot cache, using variables based on user selections in the form. The SQL string is perfect. But MS is messing it up when the PivotTable is created by dropping the { in the date format.
My code:
strSQL = “SELECT ” & strQDef & “.* ” & Chr(13) & “” & Chr(10) & ” FROM ” & strQDef & Chr(13) & “” & Chr(10) & strWhereDate & strWhereStrat & strWHERE & “;”
results in:
strSQL = “SELECT qODBCStyleQuery.*
FROM qODBCStyleQuery
WHERE (qODBCStyleQuery.AsOfDate >= {ts ‘2004-1-31 00:00:00′}) AND (qODBCStyleQuery.’Initial Investment date’ IS NULL OR qODBCStyleQuery.’Initial Investment Date’ = ts ‘2004-1-31 00:00:00′}) AND (qODBCStyleQuery.’Initial Investment date’ IS NULL OR qODBCStyleQuery.’Initial Investment Date’ <= t
Note the LACK of my { before ts in both places! MS is removing this character for some reason and then erroring out. I have tried, in vain, putting it in using ascii, using a single quote for a literal in front of it – nothing is working.
Please help!
Thank you,