当我在excel 2010中运行以下VBA代码时,它可以工作,但在excel 2013上运行时会显示错误消息。它显示编译错误:类型不匹配并突出显示rsLCC.RecordCount
Public Sub LoadRegionCombo()
Dim sLCC_SQL As String
Dim rsLCC As New ADODB.Recordset
Set rsLCC = New ADODB.Recordset
On Error GoTo Err_LoadRegionCombo
Call SetDataPath
Call OpenConnection
sQrySub1 = "CONTRACTORS"
QCArr2(0) = "COMBOS"
QCArr2(1) = "ComboSQL"
QCArr2(2) = "" ' sFilter1
QCArr2(3) = "" ' sFilter2
QCArr2(4) = "ASC"
QCArr2(5) = sQrySub1
QCArr2(6) = "" 'sQrySub2
sLCC_SQL = QryCall2(QCArr2())
rsLCC.Open sLCC_SQL, ExelCon, adOpenKeyset, adLockReadOnly
ipCount = rsLCC.RecordCount
答案 0 :(得分:3)
包装
.RecordCount
带
CLng(.RecordCount)