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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Multiple Queries 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]
 
That's a healthy attitude towards 'DoCmd Dot' use as far as I'm concerned. This is better 'performance wise' as well:


Dim strStateCode as String
Dim db as Database
Set db = DBEngine(0)(0)
... ' other declarations

strStateCode = "DC" '...happend to be on my mind.

db.Execute "UPDATE [tblStateTaxRates] set [rate]= 6.5
WHERE [STATE] = """strStateCode & """")

... updates the sales tax table record for the state code provided. Now, update some other table based on the new information...

db.Execute "UPDATE [tblORDERS], [tblStateTaxRates] Set [taxrate] = [tblStateTaxRates].[rate] WHERE [tblORDERS].[STATE] = [tblStateTaxRates].[STATE]" 'helps the orders flow.

... or something like that. The beauty of this is that you can do some error trapping, using the 'Errors' object, for each query. So if one fails or does someting odd for some reason you can branch accordingly. ;-) [sig]<p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top