Exporting to excel using a SQL statement

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

Guest

Is is possible to export to excel using a SQL statement instead of a query?
I need to be able to filter or apply a WHERE condition to the query before
the export.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "MyQuery",
"C:\Test\" & Me.cboBox & ".xls"

Any suggestions?

Thanks,
Bob
 
Is is possible to export to excel using a SQL statement instead of a query?
I need to be able to filter or apply a WHERE condition to the query before
the export.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "MyQuery",
"C:\Test\" & Me.cboBox & ".xls"

Any suggestions?

Thanks,
Bob

No you can't. It must be a Table or a Select query.

There is no problem using a query.
Just add criteria asking for the parameters, i.e.
Where TableName.ClientName = [Enter Client Name];

You'll get prompted and then the data will be exported.

Using an unbound form to both select the Client (from a combo box),
and run the transfer spreadsheet would be easy and avoid the prompt
completely.

Where TableName.ClientID = forms!FormName!ComboName
 
Back
Top