错误:“不支持连接expression式”

我试图查询使用JET连接的Excel工作簿中的几个命名的范围,并收到错误(运行时错误“-2147217900(80040e14)”:不支持连接expression式)当我试图添加第二个条件其中一个连接:

Dim strQuery As String strQuery = "SELECT mrx.Underlying " strQuery = strQuery & ",mrx.[exp] " strQuery = strQuery & ",sum(mrx.[codc]) " strQuery = strQuery & ",max(mapDt.[Str]) " strQuery = strQuery & "FROM ((([dataMRX] AS mrx " strQuery = strQuery & "LEFT OUTER JOIN [mapDt] AS mapDt on " strQuery = strQuery & "(mrx.[exp] = mapDt.[DtNumeric])) " strQuery = strQuery & "LEFT OUTER JOIN [mapUdl] AS mapUdl on " strQuery = strQuery & "(mrx.[Underlying] = mapUdl.[rmpUdl])) " strQuery = strQuery & "LEFT OUTER JOIN [dataTtm] AS ttm on " strQuery = strQuery & "(ttm.[Underlying] = mapUdl.[ttmUdl] " strQuery = strQuery & "AND ttm.[End Month] = mapDt.[Dt])) " strQuery = strQuery & "GROUP BY mrx.Underlying, mrx.[exp] " strQuery = strQuery & "ORDER BY mrx.Underlying DESC " 

具体来说,如果删除最后一个左外连接(ttm.[Underlying] = mapUdl.[ttmUdl]tmm.[End Month] = mapDt.[Dt])的第一个或第二个连接条件,查询就可以正常工作。 但是,在这两种情况下,我得到一个错误。

我正在使用JET 4.0:

 strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile _ & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";" 

我不是很确定这是正确的,但它确实用Jet引擎执行。 请试一试。

 SELECT sub.Underlying ,sub.[exp] ,sum(sub.[codc]) ,max(sub.[Str]) FROM ( SELECT mrx.underlying, mrx.exp, mrx.codc, mapDt.Dt, mapDt.str, mapUdl.ttmUdl FROM ( [dataMRX] AS mrx LEFT OUTER JOIN [mapDt] AS mapDt on (mrx.[exp] = mapDt.[DtNumeric]) ) LEFT OUTER JOIN [mapUdl] AS mapUdl on (mrx.[Underlying] = mapUdl.[rmpUdl]) ) as sub LEFT OUTER JOIN [dataTtm] AS ttm on ((ttm.[Underlying] = sub.[ttmUdl]) AND (ttm.[End Month] = sub.[Dt])) GROUP BY sub.Underlying, sub.[exp] ORDER BY sub.Underlying DESC