docmd.TransferSpreadsheet

D

Doug

I am trying to use the transferspreadsheet docmd in VBA using a sql select
statement against a SQL Server database as follows:

strsql = "select * from tbldoctoroffice where officecode = 2"
DoCmd.TransferSpreadsheet acExport, 8, strsql, "c:\doctoroffice.xls",
True, ""

It does not like the SQL. Is there a way to use a sql statement with the
transferspreadsheet command?
 
K

Ken Snell [MVP]

No. You must save the SQL into a query and then use the query in the
TransferSpreadsheet action/method.
 

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