Runtime Error 2453 Report name is either misspelled, not open or doesn't exist.
or I get a type mismatch
My curiosity is waning. I'm not sure it can be done this way, but here what I did do.
I listed my queries in the table. Where I had no query, I open the report and grab the record source there, then I call the same function, passing the same arguments from either side. This works. It is not as elegant as I would like, but it still passes muster. Here's my function.
Code:
Public Function ExportQuery(strRecordSource, strReportName)
strFileName = CurrentProject.Path & "\Excel\" & strReportName & Format(Date, "_yyyymmdd") & ".xls"
CurrentDb.QueryDefs("qryExportReport").SQL = strRecordSource
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryExportReport", strFileName
MsgBox "This report has been exported to " & vbNewLine & vbNewLine & strFileName
End Function
Thank you though.