docmd.TransferSpreadsheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
No. You must save the SQL into a query and then use the query in the
TransferSpreadsheet action/method.
 
Back
Top