I have the following code which for some reason ended up dropping the source table, any ideas why that happened?
SQL:
Sub ImportBookingsTable()
Dim db As DAO.Database
Dim sourceDB As String
Dim sourceTable As String
Dim destinationTable As String
' Set the source database and table
sourceDB = "someOtherDB.accdb"
sourceTable = "tbl_bookings"
destinationTable = "tbl_local_bookings"
' Initialize error handling
On Error GoTo DropTableError
' Delete existing table if it exists
'DoCmd.RunSQL "DROP TABLE " & destinationTable
' Reset error handling for the import process
On Error GoTo InsertError
' Import the table from the source database to the current database
DoCmd.TransferDatabase acImport, "Microsoft Access", sourceDB, acTable, sourceTable, destinationTable, False
' Success message
MsgBox "Synched", vbInformation, "Success"
' Reset error handling
On Error GoTo 0
Exit Sub
DropTableError:
' If the drop table command fails, continue to import process
Resume Next
InsertError:
' Error message for the import process
MsgBox "An error occurred during the SQL insert operation: " & Err.Description, vbCritical, "Error"
' Reset error handling
On Error GoTo 0
End Sub