I have code written to export 30+ queries to excel using the same date parameters. It runs and creates all of the export files but each file only contains the field headers and none of the data. I have included the code below. Please let me know if there is something I am missing.
Private Sub cmdReports_Click()
Dim qrys As DAO.QueryDefs 'You need a reference to DAO
Dim qry As DAO.QueryDef
strFilePath = "M:\Internal Audit\PCard and IExpense\"
Set qrys = CurrentDb.QueryDefs 'skip database variable / only needed once
For Each qry In qrys
If Left(qry.Name, 9) = "Quarterly" Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, qry.Name, strFilePath & qry.Name & ".xls"
End If
Next
Set qry = Nothing
Set qrys = Nothing
End Sub
Private Sub cmdReports_Click()
Dim qrys As DAO.QueryDefs 'You need a reference to DAO
Dim qry As DAO.QueryDef
strFilePath = "M:\Internal Audit\PCard and IExpense\"
Set qrys = CurrentDb.QueryDefs 'skip database variable / only needed once
For Each qry In qrys
If Left(qry.Name, 9) = "Quarterly" Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, qry.Name, strFilePath & qry.Name & ".xls"
End If
Next
Set qry = Nothing
Set qrys = Nothing
End Sub