Hello all,
I am using the below code to replace data in a table. The data is contained in a stored Excel File. The code works, however, after it runs it adds an additional table called "Name Autocorrect Save failure." - and a new record is added to that table each time I run the code.
In addition, the autonumber "ID" field continues to increment, even after the code deletes all the records before replaing them - can I reset the autonumber in the code? I would be grateful for any help!
I am using the below code to replace data in a table. The data is contained in a stored Excel File. The code works, however, after it runs it adds an additional table called "Name Autocorrect Save failure." - and a new record is added to that table each time I run the code.
In addition, the autonumber "ID" field continues to increment, even after the code deletes all the records before replaing them - can I reset the autonumber in the code? I would be grateful for any help!
Code:
Dim MyInt As Integer
MyInt = MsgBox("Are you sure you would like to " & _
"clear the existing records and replace " & _
"them with the most recent data?", vbYesNo + vbQuestion, "Title")
If MyInt = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL ("Delete FROM TableName")
Me.Requery
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "TableName", "C:\text.xlsx", True, "b4:l5000"
DoCmd.SetWarnings True
Me.Requery
MsgBox "The source data has been updated.", vbExclamation, "Title"
End If