Access 2010编译错误未定义用户定义的类型 [英] Access 2010 compile error User-defined type not defined
问题描述
我将2003年的数据库转换为2010年,而2003年创建的VBA脚本在2010年无法正常工作.我收到一条消息,提示存在Complie错误-未定义用户定义的类型.我没有使用VBA脚本的经验,也没有创建脚本,但是了解该脚本正在数据库中完成的操作.它突出显示的特定项目是DIM adoConn As New ADODB.Connection.
I converted a 2003 database to 2010 and VBA scripting created in 2003 is not working in 2010. I am getting the message that there is a Complie Error - User-defined type not defined. I do not have experience with VBA scripting and I did not create the script but understand that action that it is completing within the database. The specific item it highlights is the DIM adoConn As New ADODB.Connection.
我将脚本包括在内,因为所执行的操作对我们的工作流程而言是一项重要资产,因此任何帮助将是有益的.
I am including the script any assistance will be beneficial as the action that is performed is a great asset to our workflow.
Private Sub Error_code_exit(Cancel As Integer)
On Error GoTo Error_code_exit
Dim strSQLErrorCode As String
Dim adoConn As New ADODB.Connection
Dim adoRSErrorCode As New ADODB.Recordset
Set adoConn = CurrentProject.Connection
strSQLErrorCode = "SELECT [Error Matrix1].[Error Code], [Error Matrix1].CTC FROM [Error Matrix1];"
adoRSErrorCode.Open strSQLErrorCode, adoConn, adOpenKeyset, adLockOptimistic
If Not adoRSErrorCode.EOF Then
Do
If adoRSErrorCode.Fields("Error Code") = Me.Error_Code.Value Then
If IsNull(adoRSErrorCode.Fields("CTC")) Then
Me.chkAgree = True
Exit Do
End If
End If
adoRSErrorCode.MoveNext
Loop Until adoRSErrorCode.EOF
End If
adoRSErrorCode.Close
adoConn.Close
Exit_code_exit:
Exit Sub
Error_code_exit:
MsgBox Err.Description
Resume Exit_code_exit
End Sub
推荐答案
您需要设置对ADODB库的引用.是:
You need to set a reference to the ADODB library. It is :
Microsoft ActiveX Data Objects x.x Library
在代码窗口中,选择工具"->引用",然后向下滚动到所需的引用,然后在其上打勾.如果您使用DAO记录集,并且未明确将它们定义为DAO.Recordset
In the code window, choose Tools->References and scroll down to the reference you need, then tick it. You may have another problem with your code if you use DAO recordsets and they are not explicitly defined as DAO.Recordset
这篇关于Access 2010编译错误未定义用户定义的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!