EDIT: Changed as I have a different issue with the same code
2nd Edit: Adding additional code that seems to be casuing the issue
I have created a vba program in access that aggregates data from a number of external sources and write the results into a new table. Ideally when I run the program I want to wipe out all of the data that is currently in the table and replace it with my new data. I am currently currently deleting all of the data in the table… then writing my new data
Here is the code for reference
Function getTestFixtures(FixtureName As String) As Recordset
Dim db As Database
Set db = OpenDatabase(GetDBPath & "TestFixtures.xlsx", False, False, "Excel 12.0;HDR=Yes;")
If db Is Nothing Then
MsgBox "Can't find the file!", vbExclamation, ThisWorkbook.Name
Exit Function
End If
Set getTestFixtures = db.OpenRecordset("Select * from [" & FixtureName & "$]")
End Function
The recordset created above is modified and the output data is placed in a dictionary and passed to this function.
Sub Write_OTDC_Data(POlist As Dictionary)
Dim Rst As Recordset
DoCmd.SetWarnings False
DoCmd.runsql "Delete * from [OTDC Results]"
DoCmd.SetWarnings True
Set Rst = CurrentDb.OpenRecordset("OTDC Results")
With Rst
For Each key In POlist.Keys
.AddNew
For i = 0 To 9
.Fields(i).value = POlist(key)(i)
Next
.Update
Next
.Close
End With
End Sub
My Problem is that I get the following error if I try to change anything after running both of the above procuedures.

Running either in isolation does not generate the error.
I’m unsure whether this question is still unresolved. In case it’s not, I have some suggestions for you to try, but not a lot of confidence they will cure the problem.
Try
DoCmd.TransferSpreadsheetto import the sheet’s data into a scratch table instead of using OpenDatabase with the workbook.In your
MsgBox, I wonder whetherThisWorkbook.Namemeans anything to an Access application. Aside from that, I would check whether the workbook exists, then open it (or import the sheet from it) only if the file is found.Actually I’m unclear why you don’t get an error from
OpenDatabaseif the workbook file doesn’t exist. And that makes me suspicious ofDoCmd.SetWarnings FalseNever, ever turn SetWarnings off. Doing so suppresses important information. And it is completely unnecessary. Set a DAO.Database object variable toCurrentDB(), then use this instead:Add an error handler to deal with any problems dbFailOnError exposes.
Finally, this bears repeating because it’s so important. NEVER turn SetWarnings off.