在Excel 2013中键入不匹配错误,但在使用ADODB.Recordset时在excel 2010中有效

时间:2013-11-07 16:05:58

标签: excel-vba excel-2013 vba excel

当我在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

1 个答案:

答案 0 :(得分:3)

包装

.RecordCount 

CLng(.RecordCount)