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

Export to Excel Error 1

Status
Not open for further replies.

SysDupe123

Technical User
Dec 17, 2003
74
US
I'm havign trouble with some code to export to Excel. I keep getting a too few parameters error. Please Help!

Here is the code I'm using.

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Dim intStart As Integer

Dim appXL As Excel.Application


Set dbs = CurrentDb


Set appXL = New Excel.Application

'Select the data you want to output !!!Here is where it happens!!!
Set rst = dbs.OpenRecordset("SELECT * FROM [qryMou];")

'Open the receiving book and activate the required sheet
appXL.Workbooks.Open "c:\OutputTest.xls"
appXL.Worksheets("Output2").Select
 
Seems that qryMou is a parametized query, isn't it ?
Why not use the TransferSpreadsheet method ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I'm trying to get the results to a particular worksheet in an existing Excel file. I do have a variable in the query, but that is set before I run this. I select a date on a form, and the query works fine, it just won't work when running this.
 
What about this ?
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim rst As DAO.Recordset
Dim intStart As Integer
Dim appXL As Excel.Application

Set dbs = CurrentDb
Set appXL = New Excel.Application
Set qdf = db.QueryDefs("qryMou")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top