Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1116
  • Last Modified:

How to force MS Access to WAIT for an append (or any) query to finish, before it moves on to next statement?

Using a SQL-Server back-end, it appears that a long-running union-query is 'kicked off' in a macro (also tried it in a function) and then execution immediately proceeds to the next line of the macro (or function).
Is there a way to make execution WAIT for completion of each query, before continuing on to execute the next?

For years, I've always assumed that a macro with OpenQuery actions just naturally waited until each query is completed before moving on....

Probably something simple.  Any thoughts?
Thanks in advance
1
bcreen
Asked:
bcreen
  • 2
1 Solution
 
IrogSintaCommented:
Actually, that's the first I heard of something like this.  Are you certain this is indeed happening?  Have you tried adding some debug.print statements with time stamps and record counts?
0
 
bcreenAuthor Commented:
I resolved this myself by changing docmd.openquery.... statements to dbs.execute .... statements.
Now, how in the world do I DELETE this question?
0
 
bcreenAuthor Commented:
CurrentDatabase.Execute SQL, dbFailOnError statements -- against a SQL-server backend database -- complete the SQL statement BEFORE moving on to the next statement in VBA code or in a macro of multiple queries to be executed.

I had formerly macros and VBA code that had a series of queries that were being executed by DoCmd.OpenQuery (SQL, dbOpenForwardOnly) statements.

Turns out these statements execute sequentially, but often before the prior query has finished.... thus causing havoc, when one has "assumed" they would each FINISH before the next one started!  Especially true for long-running Union queries....
1

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now