Gettting number of Recs, ADO Open with adOpenForwardOnly, adLockReadOnly

I am trying to speed up a long running process in a clients Access 2013 application by among other things, changing the open of the recordsets involved in the process from

1.  rsIn.Open selectString, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
to
2.  rsIn.Open selectString, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly

When I was using 1. I could check the number of records in the result set with wkTotRecs = rsIn.RecordCount

I then put a counter on the screen showing the total number of records and which records was being processed.  

'Processing 23 of 125'

I find this to be much more meaningful to the users that the status bar.

When I open with 2., rsin.Recordcount always is -1.

Is there an efficient way to get the number of records in the result set while using format 2.?

I know I could do a count() but that seems like it would be processing the file twice.  One to get the count and one to read the records.  Dcount would also work but that would also increase the overhead, which I am trying to reduce.

I think adCursorLocation can accomplish this but I'm not sure how to set it.
LVL 1
mlcktmguyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fabrice LambertFabrice LambertCommented:
Since the recordCount property is only reliable after you reach the end of the recordset, and it doesn't matter with forward-only recordsets, I'm afraid the only option is running a count() query.
Limit the query to only one column tho, to reduce server load / data traffic.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aikimarkCommented:
You could do a .MoveLast, get the Absoluteposition property, and then .MoveFirst

This technique does not work with a forward-only recordset
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.