vba Access 2013 项目中不存在 ADODB,如何添加对它的引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22845278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ADODB doesn't exist in Access 2013 project, how do I add a reference to it
提问by John S
I am trying to rebuild an Access adp project in Access 2013 as and mdb. The tables are all linked tables in both version so that is not an issue.
我正在尝试在 Access 2013 as 和 mdb 中重建一个 Access adp 项目。这些表在两个版本中都是链接表,所以这不是问题。
I have imported the forms from the old project so the form layouts and code is all there.
我已经从旧项目导入了表单,所以表单布局和代码都在那里。
Where I run into problems is when trying to execute the following code:
我遇到问题的地方是在尝试执行以下代码时:
Dim cmd As New ADODB.Connection, RS As New ADODB.Recordset
cmd.ActiveConnection = connectionString
Debug.Print connectionString
cmd.ActiveConnection.CursorLocation = adUseClient
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_Myproc"
cmd.Parameters.Refresh
cmd(1) = Me.my_id
Set RS = cmd.Execute
'Should be checking if record set is open and explicitly close it. JWS
If RS.State = 1 Then
RS.Close
Set RS = Nothing
End If
cmd.ActiveConnection.Close
I am not able to declare the cmd and RS variables because ADODB doesn't seem to exist. How do I reference this in Access or what is the correct way to accomplish this?
我无法声明 cmd 和 RS 变量,因为 ADODB 似乎不存在。我如何在 Access 中引用它或完成此操作的正确方法是什么?
回答by Barranka
As I wrote in my comment, you need to check that the ADODB reference is enabled:
正如我在评论中所写,您需要检查 ADODB 引用是否已启用:
- On the VBA Editor, clic on the "Tools" menu, and then clic on "References..."
- Verify thet the checkmark for "Microsoft ActiveX Data Objects x.x Library" is activated; if it is not, activate it.
- 在 VBA 编辑器上,单击“工具”菜单,然后单击“引用...”
- 验证“Microsoft ActiveX Data Objects xx Library”的复选标记是否已激活;如果不是,请激活它。
Further reference: Using ADO with Microsoft VB & VBA