【发布时间】:2020-12-20 16:51:06
【问题描述】:
从某些单元格中为我的 SQL 提取值时出现以下错误。但是,当我将值硬编码到代码中时,它可以正常工作。所以,这显然与我编写它的语法有关。
出于几个原因,我希望使这种动态变化,并希望有人可以帮助我。
错误:Microsoft Access 数据库引擎找不到对象“objectname”
值被硬编码的工作代码:
mySQL = "SELECT * FROM [listname];"
With cnt
.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=0;RetrieveIds=Yes;DATABASE=https://sharepoint.com/sites1/xx/;LIST= {0C3G7BTF-000E-4C16-8E07-E4B7F525069F};"
.Open
End With
不起作用的代码:
mySQL = "SELECT * FROM ['" & Sheet3.Range("c1") & "'];"
With cnt
.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=0;RetrieveIds=Yes;DATABASE=https://sharepoint.com/sites1/xx/;LIST= {'" & Sheet3.Range("d1") & "'};"
.Open
End With
【问题讨论】:
标签: sql vba excel-2007