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

Running SQL in a batch

Status
Not open for further replies.

mflower

MIS
May 6, 2001
52
0
0
NZ
Hi
Anyone knows how I can run SQL queries in a batch..i.e. running strSQL one after another. For example, SELECT * FROM TABLE1 and then after that run SELECT * FROM TABLE2?
Thanks in advance.
mflower
 
You could do it in a module by stacking your commands.

If they are update queries you would say...
DoCmd.RunSQL "INSERT..."
DoCmd.RunSQL "INSERT..."

If they are select queries you would say...
DoCmd.OpenQuery "Query1"
DoCmd.OpenQuery "Query2"

Please elaborate if this is not what you mean.

lonniejohnson@prodev.com
ProDev, MS Access Applications B-) ,
May God blow your mind with His Glory in 2003.
 
Thanks Lonnie.
I'll need to run a OpenQuery first but will need to get it changed each time. Then run the strSQL.

Run OpenQuery (change the filter) in the Module
Then run strSQL
Run OpenQuery (change the filter again) in the Module
Then run strSQL

Will this work? Thanks.
 
Yes it will. Look at the QueryDef object in MS Access help. This is where you can programatically change properties of a query (even the entire SQL) before running it.

Give me more detail if you require more help.

lonniejohnson@prodev.com
ProDev, MS Access Applications B-) ,
May God blow your mind with His Glory in 2003.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top