Connecting Tech Pros Worldwide Forums | Help | Site Map

Export Parameter Query Results to Excel

Newbie
 
Join Date: Mar 2007
Posts: 4
#1: Mar 26 '07
Hello,
I have a parameter query called 'Rev by AcctCode' that takes it's value from a form field; Forms![SalesAssoc]![e-mail].

I am trying to find a way to run this query, get the parameter value to it, and populate an Excel spreadsheet with the results.

Apparently, there is no direct way to use TransferSpreadsheet with a parameter query.

Instead, could I somehow get the results into a QueryDef, then use the named QueryDef with TransferSpreadsheet?

How might I do this? Can anyone point me to sample code?

Thank you for your help!

cdun2.
nico5038's Avatar
Moderator
 
Join Date: Nov 2006
Location: The Netherlands
Posts: 2,232
#2: Mar 27 '07

re: Export Parameter Query Results to Excel


You can fill a query like:

dim qd as dao.querydef ' Make sure that Microsoft DAO version #.## is checked under Tools/References!

set qd = currentdb.querydefs("your_query_name")
qd.SQL = "select x from tblY where ID=" & me.ID

docmd.transferspreadsheet ... "your_query_name"

Getting the idea ?

Nic;o)
Reply