【发布时间】:2014-08-17 17:26:22
【问题描述】:
我正在尝试从 excel 访问中运行查询,然后使用 VBA 中的 ADO 将这些结果提取到 excel 文档中。不幸的是,我无法弄清楚如何运行访问查询,以便将 Excel 工作表的活动单元格中的数据用作访问查询中的条件。
我正在运行 Excel 和 Access 2007。我在下面包含了我目前拥有的代码。在此先感谢您的帮助。
Sub testdb()
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Set con = New ADODB.Connection
With con
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Open "H:\WBC\Lukas\STOP.accdb"
End With
con.Execute "HPRSearch"
'the criteria field is 'Input', and I need to pull it from the active cell on the Excel Sheet
End Sub
【问题讨论】:
标签: vba excel ms-access-2007 ado