Hi all,
Im trying to export the results of a VBA query which populates a listbox to Excel. If I use DoCmd.TransferSpreadsheet acExport I get the error invalid use of null but I can see there is data in the listbox. Any ideas please - code below:
Code:
Private Sub ExportTotal_btn_Click()
Dim strSQL As String
Dim strQry As String
Dim sQryOutput As String
sQryOutput = Me.TotalHrs_Listbox.Value
strSQL = "SELECT * FROM sQryOutput"
strQry = "TempQueryName"
Set db = CurrentDb
Set qdf = db.CreateQueryDef(strQry, strSQL)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, _
strQry, "D:\Folder\output.xlsx", True
DoCmd.DeleteObject acQuery, strQry
End Sub
Thanks