Hey all,
Ok, i'm trying to output some queries to an excel file. I need to pass some criteria. I'm hoping to only use one query and not have to duplicate them all for each instance.
Here's what i'm trying....
....but the the output object name (sql) isn't happy. It expects the actual query name which works fine but hasn't got the criteria (courier) passed to it.
Is there a way to achieve what i'm trying????
Thanks. Spin.
Ok, i'm trying to output some queries to an excel file. I need to pass some criteria. I'm hoping to only use one query and not have to duplicate them all for each instance.
Here's what i'm trying....
Code:
'output to sheet1
sql = "select * from Qry_Claims_Damaged_by_Courier " & _
"where courier = '" & courier & ""
DoCmd.OutputTo acOutputQuery, sql, acFormatXLS, pth
'output to extra sheets
sql = "select * from Qry_Claims_Lost_by_Courier " & _
"where courier = '" & courier & "'"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, sql, pth
....but the the output object name (sql) isn't happy. It expects the actual query name which works fine but hasn't got the criteria (courier) passed to it.
Is there a way to achieve what i'm trying????
Thanks. Spin.