TransferSpreadsheet and parameter query help?

C

chemicals

I need to run a query with a parameter and then output the results to a
spreadsheet.
I can use TransferSpreadsheet to read from a table - this works fine. I
need to do it with a parameter query to a SQL Server. I am using ADO for all
my database access..

Does TransferSpreadsheet alloe the passing of a query AND a parameter? I
can't seem to make it work.

Thanks
 
C

chemicals

here is the code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"get_materials, modInit.strOutputPath & modInit.ContractCode &
"_MaterialsList.xls", True

"get materials" is a query requiring a parameter...

I also want this to be done in the background (i.e. no UI control from form)
 
R

ryguy7272

If this is a crosstab query, you must declare the parameter in the query.
It's a good idea to do that anyway. Choose Parameters on the query menu,
enter the full name of the parameter, and indicate the data type.

How can I return based upon strings? For example if a param is "al", return
alaska and albany.

WHERE Status Like "*" & [Param1] & "*" AND Status Like "*" & [Param2] & "*"

*aaa* will bring all the words that conatain aaa
aaa* will bring all the words that start with aaa
*aaa will bring all the words that end with aaa

Allen Browne has a nice example here:
http://allenbrowne.com/ser-67.html

I really like Martin Green's stuff too:
http://www.fontstuff.com/access/acctut01.htm

Regards,
Ryan---
 

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

Top