Home » excel » Type mismatch error in excel 2013 but works in excel 2010 when using ADODB.Recordset

Type mismatch error in excel 2013 but works in excel 2010 when using ADODB.Recordset

Posted by: admin May 14, 2020 Leave a comment

Questions:

When I am running the following VBA code in excel 2010 it works but shows up an error message when running it on excel 2013. It shows up Compile Error : Type Mismatch and highlights 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
How to&Answers:

Wrap

.RecordCount 

with

CLng(.RecordCount)