kengooch
Member
- Local time
- Today, 07:04
- Joined
- Feb 29, 2012
- Messages
- 137
So I have a form that allows the user to filter by multiple criteria in Multi-Select List boxes.
Once the records are filtered, I need to export them to an excel spreadsheet.
I have the following code...
I get an error on the .SQL = strSQL line 7
What am I missing here? Or is there a better way to save this out to an excel sheet.
Thanks,
Ken
Once the records are filtered, I need to export them to an excel spreadsheet.
I have the following code...
Code:
Private Sub bToExcel_Click()
'Setup SQL
Dim strSQL As String
strSQL = Me.RecordSource
strSQL = "SELECT " & strSQL & " WHERE " & Me.Filter
With CurrentDb.QueryDefs("qEvntComplete")
.SQL = strSQL
End With
'Now export the query with critera to excel
Dim strOutFile As String
strOutFile = "\\R04MWVNAS21\Occupational Health\MSTools\Custom Reports\" & Format(Date, "yyyymmdd") & " Event-Staff Custome Report.xlsx"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, _
"qryExport", strOutFile, True
End Sub
I get an error on the .SQL = strSQL line 7
What am I missing here? Or is there a better way to save this out to an excel sheet.
Thanks,
Ken
Last edited by a moderator: