I am wanting to create an excel workbook and write a record set to it. I have my recordset, and I have created an excel workbook. But I am not sure how to write the recordset to it. This is the code that I have.
Dim rst As DAO.Recordset Dim userSQL As String Dim xlBook As Object Dim xlApp As Object userSQL = "SELECT Count(username) AS username FROM userdata WHERE username NOT IN (Select username FROM weekoneuserdata);" Set rst = CurrentDb.OpenRecordset(userSQL) missingUsers = rst.Fields(0) rst.Close Set rst = Nothing If missingUsers >= 1 Then continue = False Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbook.Add xlBook.SaveAs ("C:\Users\" & Environ("username") & "\desktop\Missing Data.xlsx") 'write the data to the excel file End If