I have a query which shows joined records from 2 tables. Now I want to select certain records with desired ID from that query and export them to Excel. How can I do this ?
This doesn't work :
Dim SQL As String
SQL = "SELECT * FROM Created_Query" & _
" WHERE ID=" & Me![Combobox]
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, SQL, FileName, True
I've also tried with DAO.Recordset like this:
Dim Desired As Recordset
Dim SQL As String
SQL = "SELECT * FROM Created_Query" & _
" WHERE ID=" & Me![Combobox]
Set Desired= CurrentDb.OpenRecordset(SQL, dbOpenSnapshot)
None of the above methods work. Where am I wrong ?