在命令文本中,我似乎无法使用参数作为表名,因此我现在尝试将其硬编码到VBA查询中,但我遇到了“1004”:应用程序定义或对象定义的错误。附件是我正在使用但似乎不起作用的命令文本的屏幕截图。我添加的以下代码导致了该错误:The Connection Properties pop up box
With ActiveWorkbook.Connections("Query1").OLEDBConnection
.BackgroundQuery = True
.CommandType = adCmdText
.CommandText = "SELECT * FROM [DBO].[Refresh_" & UserName & "] ORDER BY [Item No];"
End With
我将感谢任何人可以给予我关于查询“连接”属性框或vba代码的任何帮助。
先谢了保罗
1条答案
按热度按时间fnx2tebb1#
根据您设置连接的方式,它将具有
ODBCConnection
或OLEDBConnection
属性(但不能同时具有这两个属性)。如果您稍微分解一下代码,就可以监视连接并查看填充了哪些属性:
监 windows 口: