Is it possible to use the transfer spreadsheet command by specifying the SQL to run rather than referring to a table or query ?
Thus I know that the code below will run query Q1 and ouput it:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"Q1", "C:\temp\my_file.xls", True, ""
But If I have a string "Select * from [Table1]" can I insert that into the TransferSpreadsheet command somehow - if I try:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"Select * from [Table1]", "C:\temp\my_file.xls", True, ""
it falls over....
any help gratefully received
Dan
Thus I know that the code below will run query Q1 and ouput it:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"Q1", "C:\temp\my_file.xls", True, ""
But If I have a string "Select * from [Table1]" can I insert that into the TransferSpreadsheet command somehow - if I try:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"Select * from [Table1]", "C:\temp\my_file.xls", True, ""
it falls over....
any help gratefully received
Dan