Solved

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

Posted on 2013-06-15
3
920 Views
1 Endorsement
Last Modified: 2013-06-25
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
Comment
Question by:bcreen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39250761
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
 

Accepted Solution

by:
bcreen earned 0 total points
ID: 39263084
I resolved this myself by changing docmd.openquery.... statements to dbs.execute .... statements.
Now, how in the world do I DELETE this question?
0
 

Author Closing Comment

by:bcreen
ID: 39274169
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you how to use shortcut menus in the Access run-time environment.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question