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

  • Thread starter Thread starter GY2
  • Start date Start date
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.
 
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
 
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.
 
Back
Top