Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Multiple Querys in order from code

Status
Not open for further replies.

KennyJaymes

Technical User
Sep 13, 2000
5
GB
I have 4 querys that must be run in sequence in order to perform specific tasks. These querys basicly format imported data to match our own database.
One query is a select, One is a Update and the other Two are Append querys.

At present I am using a "dreaded" Macro to run them one after each other using the "OnClick" event of a command button called "Import Data from *****" but I do not like Macros.

So I wondered if:
1.
Is there some EASY way to combine all the code from these 4 querys into one so that all the tasks are completed in the correct order ?

or if the above is very complicated to do;

How do I call each query in turn from code insted of a macro.

Thanks in advance,

Kenny [sig][/sig]
 
Try Docmd.RunSQL &quot;<SQL Statement>&quot; or DoCmd.OpenQuery &quot;<Query Name>&quot;

That will take the place of macros, your other problem unfourtunately will just have to be solved from experience. We can help you with coding problems but it is very hard for us to solve another user's design problems. [sig][/sig]
 
Kenny,

The code to run a series of ACTION queries is pretty easy:

Do all the Dim things (dbas as database, qdf as querydef, idx as integer ...

Create an one dimensional array of strings.

Populate the array with the &quot;Names&quot; of the queries.

Do a loop ...

[tab]For Idx = 0 to UBound(ArayNames)
[tab][tab]set qdf = dbs.OpenQuerydefs(ArrayNames(Idx))
[tab][tab]qdf.Execute
[tab]Next Idx

That's all .... [sig]<p>MichaelRed<br><a href=mailto:mred@duvallgroup.com>mred@duvallgroup.com</a><br>There is never time to do it right but there is always time to do it over[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top