How to tell when a query is finished.....

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi all;

I have several queries that I am calling using DOCMD in VB. They have lots
of funky calculated fields, and take a long time to complete. I need to
close the queries after they are complete automatically. Is there a way I
can tell VB if a query is complete?

Thanks in Advance;
Steve
 
Steve -

Are you opening (running) an action query or just opening a Select query?
If the latter, why do you care when it finishes? Why would you want to
close it as soon as it finishes - doesn't the user need to see the result?

If the former (action query), then you don't need to close the query - it
never opens its datasheet. If you need your code to wait until the action
query finishes, you should use the Execute method of a database object.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR?pg=personal&fr_id=1090&px=1434411
 
It's a select query that has a function that writes the results to a DDE
channel. It takes a while to write these values down, and I need to ensure
it's finished before I close the query. The user doesn't see the results,
it just writes the values to DDE.

Thanks for your response.
Steve
 
Why not call the function from code? Why are you doing it from a query? If
you need to read through some records to pick up values to pass to the
function, then open the recordset in code and loop through it. That would
be much more efficient than opening the query and trying to figure out when
it's done - it would give you more control over error trapping as well.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR?pg=personal&fr_id=1090&px=1434411
 
Actually, I already changed it to do so using recordsets based on the
query's. Thanks for your help!

Cheers;
Steve
 
Back
Top