excel automation through parameter queries

G

Guest

I am extremely close on getting this working but stuck on one thing. I used
the excel export code talked about through this community to take info in my
query and export it to excel. One of my problems however was that I have 24
parameter queries that have to run...the issue is that it prompts the user 24
times for my Destination field.

Anyways, to solve this I built a form that would prompt the user once and
pass the variable into my excelExport() function. This would call all 24
queries and pass the variable into each query using the following:

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As Recordset
Dim....the rest of my variables

....All my excel export stuff

Set db = CurrentDB
Set qdf = db.QueryDefs("My Query Name")
qdf.parameters("My Query Parameter") = varDestCode

**********************************
Set rs = db.OpenRecordset("My Query Name", dbReadOnly)
strRange = "A6:D15"
objSht.Range(strRange).CopyFromRecordset rs

**** - this is where I am not sure. after I set the parameter = to the
variable passed in through my from. How do I then set recordset = my query
(w/my parameter set to my variable)???
 
G

Guest

I am now getting a data type conversion error. Any ideas. Maybe I am making a
mistake setting the parameter in the query. For my destination field, in the
criteria section I am typing [Destination]

Any thoughts?
 

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

Similar Threads

Excel Export Efficiency 2
Looping Through a Queries Results 5
Error 3061: Too Fee Parameters 2
Referencing Field names in Parameters 14
qrydef 3
fldName 4
String to Date 7
Function to Copy and Rename Queries 7

Top