First of all thanks to all posters on this forum. Though this is my first post I've already used quite a bit of answers/ example code here to solve issues in the database I'm working on.
But on this one I could not find the answer. As such my question here:
Background:
I'm hired within a project which has the goal of migrating 45000 computers to a new platform: Windows 7 with Office 2007.
For this project I manage the informationdatabase containing details on all in scope components (Computers, Useraccounts, Applications, Authorizations, etc)
The migration will be planned by clusters. A clusters is a subset of the scope based on either location, department or mixture of both. Such a cluster is assigned to a clustermanager who will be responsible for a succesfull migration.
Each clustermanager now has an information need on it's cluster. As such Users are now assigned to a clusterID.
Using query's a total of 7 views can been created. (Each query has a variable parsed containing the ClusterID).
The Clustermanagers like to have these views in a Excelsheet. with every view on a different sheet. For this a template has been created.
Of course I want this sheet to be created with a single click .
My challange
As I need to control how the data is exported I want to use automation to export the data.
However this method requeries the use of a recordset. Of which a parameter needs to be either the name of a Query or Table:
Code:
Set rst = dbs.OpenRecordset("QueryOrTableName", dbOpenDynaset, dbReadOnly)
In a simple query where no variable is used There is no issue for this.
However I want to have the ClusterID (Which is a variable in all Queries) to be passed into the query.
As such I tried to contentate the query using VBA to a string called strSQL. I then want this string to be captured by a Querydef called qdf. So I would have a query I can call by name right.
I thought I could then parse this Querdef into the Recordset as a Query.
Is this in anyway possible? And if so how would the syntax be for the Recordset. My Querydef is:
Code:
Set qdf = dbs.CreateQueryDef("Query", strSQL)
My syntax for setting the record is:
Code:
Set rst = dbs.OpenRecordset("QueryOrTableName", dbOpenDynaset, dbReadOnly)
If it is not possible to use a QueryDef in the recordset I would like to know alternatives to accoplisch what i want which is:
Exporting data to excel with control on where what is passed in the Excel sheet using Queries to fill the sheets where the querie has a variable in it.
Thanks a lot in advance for your reply.