I have a function that has 2 paramaters that are inserted into a SQL statement. I can DoCmd.OpenQuery SQL and get the correct results. However, I want to export the results to excel. I can't use DoCmd.TransferSpreadsheet or DoCmd.OutputTo because I don't have a query name. Do I need to save the sql to a querydef, run the export then kill the querydef? Is there a less cumbersome way?