Asynchronus Query

I am using an Aynchronus Query to get data because i may have end up with 40 or 50,000 records. I want to give control to user to cancel at any point to  the query. That i was able to do. But i want the total record count also for the query. When i am using recordset.recordcount it is taking a while and at this point user can not have any control to stop.
Is there a way to give control to user at this point or is there another way to get the rcordcount of my query without taking long time.

My code looks like this

rsADOTmp.Open rname, openqr_cnn, adOpenKeyset, adLockOptimistic, adAsyncExecute
      While rsADOTmp.State = adStateExecuting 'Or cn.State = adStateOpen
            GLOBAL_CenterForm frmCancel
            If SQL_Execute_cancel = True Then
                Unload frmCancel
                SQL_Execute_cancel = False
                Exit Sub
            End If
        gcount = rsADOTmp.RecordCount

Here it is taking a while.

If anybody know the answer please let me know

Who is Participating?
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.

Yes you should first get the record count by doing a recordset with :

"select count(*) from tablename where condition = x"

substituting tablename and condition as necessary.

The get the value out of the recordset and this represents the number of records that your async query will return, at a fraction of the time.

I have done this in many similar circumstances.

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
svenkatapuramAuthor Commented:

 i know that i could use count(*) to get the count of records but in my situtation i do not want to substitue table name and where. So is this the only alternative (fast one)
Yes, say your table is called Sales and the criteria is > 1/1/1998

Obviously you don't know if you have 1 or 1000000 rows so do a :

select count(*) from sales
where date > '1/1/1998'

put the result on screen somewhere, before running the async

select * from sales
where date > '1/1/1998'

Try it you will find it really neat.
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
Visual Basic Classic

From novice to tech pro — start learning today.