Hello,
***The workbook***
My workbook contains several Excel named data ranges organised as database tables.
I then use ADODB.Connection in order to use SQL SELECT statement to join these tables.
The SQL query results (ADODB.Recordset) then feed a PivotCache.Recordset object which feeds a Pivot table.
This workbook has always been working fine on Excel 2003 (using SQL engine Jet.OLEDB.4.0).
I now moved to Excel 2007 and therefore, I changed the connection string to:
***Excel 2007 returns an error where Excel 2003 was fine***
Using Excel 2007, I get a "Runtime error '-2147467259 (80004005)': Type mismatch in expression." error. This error usually occurs when trying to JOIN or UNION fields having different data types. However, in my case, my data types are all consistent as proven by the fact that the query runs fine with Excel 2003.
***What I have tested so far***
My SQL query contains the following section:
(SELECT * FROM Table1
UNION ALL SELECT * FROM Table2
UNION ALL SELECT * FROM Table3) AS Table1To3
While testing, I remarked that I don't get the above error if I only UNION ALL any two tables such as:
(SELECT * FROM Table1
UNION ALL SELECT * FROM Table2) AS Table1To3
or
(SELECT * FROM Table1
UNION ALL SELECT * FROM Table3) AS Table1To3
Therefore, it seems that ACE.OLEDB.12.0 gets confused with field data types when there are several UNION ALL while Jet.OLEDB.4.0 had no issue with that.
***Question***
Any hint as to how I could overcome the above bug?
Can I use Jet.OLEDB.4.0 with Excel 2007?
Many thanks!
Louis
***The workbook***
My workbook contains several Excel named data ranges organised as database tables.
I then use ADODB.Connection in order to use SQL SELECT statement to join these tables.
The SQL query results (ADODB.Recordset) then feed a PivotCache.Recordset object which feeds a Pivot table.
This workbook has always been working fine on Excel 2003 (using SQL engine Jet.OLEDB.4.0).
I now moved to Excel 2007 and therefore, I changed the connection string to:
Code:
= "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & MainSourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=Yes"";"
***Excel 2007 returns an error where Excel 2003 was fine***
Using Excel 2007, I get a "Runtime error '-2147467259 (80004005)': Type mismatch in expression." error. This error usually occurs when trying to JOIN or UNION fields having different data types. However, in my case, my data types are all consistent as proven by the fact that the query runs fine with Excel 2003.
***What I have tested so far***
My SQL query contains the following section:
(SELECT * FROM Table1
UNION ALL SELECT * FROM Table2
UNION ALL SELECT * FROM Table3) AS Table1To3
While testing, I remarked that I don't get the above error if I only UNION ALL any two tables such as:
(SELECT * FROM Table1
UNION ALL SELECT * FROM Table2) AS Table1To3
or
(SELECT * FROM Table1
UNION ALL SELECT * FROM Table3) AS Table1To3
Therefore, it seems that ACE.OLEDB.12.0 gets confused with field data types when there are several UNION ALL while Jet.OLEDB.4.0 had no issue with that.
***Question***
Any hint as to how I could overcome the above bug?
Can I use Jet.OLEDB.4.0 with Excel 2007?
Many thanks!
Louis