Excel query record count differs from MS-Access count

P

Peter Bassett

I can't figure out why I get the wrong record count when I run the query in
Excel VBA versus directly from the MS-Access query list.

There are 531 records in the MS-Access query results but I get an incorrect
655 records in Excel VBA. The extra records are not duplicates; they do not
belong (they are form a different school than DeVry).

Here is the relevant code:

Set dbmain = New ADODB.Connection
dbmain.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath

sqlstr = "SELECT [Enrollment Location Code], [Student Last Name], [Student
First Name], " & _
"[DSI#], [E-mail Address], [F1], [F2], [F3], [Metro] " & _
"FROM [***qryDeVryUnduplicatedHoldsByStudent];"

Set rcset = New ADODB.Recordset
rcset.Open sqlstr, dbmain, adOpenKeyset, adLockOptimistic
recordCount = rcset.recordCount


I don't see how this can return a different record set than running the
query directly. Aby help is greatly appreciated.

Thanks,
Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top