问题描述
我正在尝试在 Access 2013 as 和 mdb 中重建 Access adp 项目.两个版本中的表都是链接表,所以这不是问题.
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.
我已经从旧项目中导入了表单,所以表单布局和代码都在那里.
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
我无法声明 cmd 和 RS 变量,因为 ADODB 似乎不存在.我如何在 Access 中引用它或完成此操作的正确方法是什么?
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?
推荐答案
正如我在评论中所写,您需要检查 ADODB 引用是否已启用:
As I wrote in my comment, you need to check that the ADODB reference is enabled:
- 在 VBA 编辑器上,单击工具"菜单,然后单击引用..."
- 验证Microsoft ActiveX 数据对象 x.x 库"的复选标记是否已激活;如果不是,请激活它.
进一步参考:使用ADO 与 Microsoft VB &VBA
这篇关于Access 2013 项目中不存在 ADODB,如何添加对它的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!