I have a macro that saves monthly data to an Access database in Access 2013 using the DoCmd.TransferSpreadsheet method. A possible situation I want to account for is if data is saved to the database and then someone realizes that the data was wrong and they want to rearchive the data for the month in question after they fix the data. In other words, is there a way for me to change my code to overwrite data for the same month as the data that will be archived?
One of the fields in the data that is archived is the date, and it also has a field name as well. Another important thing to know is that the data that needs to be overwritten would all be in the same month, but not necessarily the same day. Here's a simplified example of what the "my_data" array would look like in excel:
Sub excel_export()
Dim xls_path As String
xls_path = "C:\mywbk.xlsm"
Dim db_path As String
Dim db_obj As Access.Application
db_path = "C:/mydb.accdb"
Set db_obj = New Access.Application
Call DoCmd.TransferSpreadsheet(acImport, acSpreadsheetTypeExcel12Xml, "TableName", _
xls_path, True, "my_data")
db_obj.CloseCurrentDatabase
Set db_obj = Nothing
End Sub