Access 2013错误绑定到ADO Recordset

时间:2014-02-10 07:45:25

标签: ms-access access-vba ms-access-2013

我正在尝试使用“Microsoft ActiveX Data Objects 2.8 Library”将连续表单绑定到ADO Recordset。当我尝试将记录集绑定到我的表单时,我收到以下错误:

3265 Item cannot be found in the collection
corresponding to the requested name or ordinal.

这是我的代码:

Dim cn As New ADODB.Connection, rs As New ADODB.Recordset
cn.ConnectionString = "Driver={MySQL ODBC 5.2 ANSI Driver};" & _
    "Server=redacted;Database=redacted;" & _
    "User=redacted;Password=redacted;"
cn.Open
rs.Open "SELECT * FROM device", cn, adOpenStatic, adLockReadOnly
'I can debug.print records and fields right here
Set Me.Recordset = rs 'Error happens here
cn.Close
Set cn = Nothing

我在Windows 8.1 64位上使用Office 2013 32位和MySQL 32位ODBC驱动程序(无法从32位应用程序调用64位驱动程序)。

1 个答案:

答案 0 :(得分:3)

嗯,问题仍然存在于Access 2010 / Win7上。但我通过在运行Open方法之前指定光标位置来修复它:

rs.CursorLocation = adUseClient
rs.Open "SELECT * FROM device", cn, adOpenStatic, adLockReadOnly