How to load current database query results into Recordset(2)?

G

GY2

I want to write a VBscript that will be kicked off by Windows Scheduler. The
script should open an Access 2007 accdb file (via OpenDatabase?) and then
(using currentdb.openRecordset?) shove the results of a saved query into a
recordset through which I can step completely one time.

The query's SQL is fairly long so I wonder is there a way to just refer to
it by its name in the accdb file instead of having to stick the entire string
into my function? Can a command object be a query name? Can the Source
argument be a query name?

I'm guessing this is all less that 5-6 loc. All help really appreciated.
 
D

David H

Yes it is possible. You can either create a query in Access and then open it
via code or use the SQL directly in the script. The article below will show
you how to open an existing query in Access and loop through the articles.
The article is geared toward manipulating Access from Excel, however it
includes the key objects and methods for working with QueryDef objects and
should get you started.

http://support.microsoft.com/default.aspx/kb/151511
 
D

David H

GY2 said:
I want to write a VBscript that will be kicked off by Windows Scheduler. The
script should open an Access 2007 accdb file (via OpenDatabase?) and then
(using currentdb.openRecordset?) shove the results of a saved query into a
recordset through which I can step completely one time.

The query's SQL is fairly long so I wonder is there a way to just refer to
it by its name in the accdb file instead of having to stick the entire string
into my function? Can a command object be a query name? Can the Source
argument be a query name?

I'm guessing this is all less that 5-6 loc. All help really appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top