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

VBA to run select statement of query

Status
Not open for further replies.

Fherrera

Technical User
May 11, 2004
129
CA
Hi, I'm going to be making a "script" of sorts that will run many SELECT statments, but these SELECT statements will be using a query as the table...or selecting a query, however it is said.

ie. SELECT * FROM thisQuery (which is a query defined in the queries section of Access 97)

Except, that to run all these select statements the thisQuery will have to be different. And I don't want to create the 84 thisQueries I need. Is there another way of running a SELECT statement that queries directly on the RESULTS of another query. I've tried using the

SELECT A.Tag FROM (SELECT blah blah ) AS A

but I keep getting a syntax error in the FROM clause...

I don't particularly want to make a table of the thisQuery portion, but I suppose that is one option, a table that I can promptly delete right after it is used.

Also, another question I have is what is more efficient and easier to do: to create VBA code to run queries in Access and return the results to Excel, or to code VBA in Access that runs queries and exports into Excel spreadsheets? Efficient, easier...maybe faster?

Thank you

Frank
 
My preference goes to pulling data instead of pushing.
Furthermore in Excel you can play with parametized QueryTables even if you forget to choose MS-Query during the installation of office.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top