I am trying to add a new record to a recordset using the code below:
Code:
Public Sub formatExcelReports()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Dim xlWbk As Object
Dim ws As Object
Dim lCol As String
Dim rs As DAO.Recordset
Dim sSQL As String
sSQL = ""
sSQL = "SELECT DISTINCT * FROM tblFilesToSend"
Set rs = CurrentDb.OpenRecordset(sSQL)
th:
On Error GoTo th
rs.AddNew 'it always errors out on this line, why?
rs![File Name] = "Guaranteed_All.xlsx"
rs![Relationship Office] = "All"
rs.Update
but it always errors out on the line rs.addNew.
I don't understand why?