Need to Kill Original Table in Access Import

JMarcus

Registered User.
Local time
Today, 15:44
Joined
Mar 30, 2016
Messages
89
I have to add a step to kill the last import of the file. Essentially, it will replace the existing table in the import. Do I use the kill file code?

Code is as follows:

DoCmd.TransferSpreadsheet acImport, 10, _
"Portal Mail List", CurrentProject.Path & "\Portal Mail List.xlsx", True
MsgBox "Data import completed", vbInformation, "Completed"
 
Are you removing the file used for import OR the data in the table you import to?

Kill will work with the file and an action query (delete) would resolve the import table.
 
Killing the existing table in access not the import file
 
use Drop Table

DbEngine(0)(0).Execute "Drop Table [Portal Mailing List];"

ofcourse if it is already deleted error will occur, so add, before this code:

On Error Resume Next
 
You just need a Delete query for the relevant table. EG
Code:
DELETE [Portal Mail List].*
FROM [Portal Mail List];

This will delete all the records leaving it blank for import. Either run it before import (if you use the data after import) or after.
 
This worked out good with the delete query and added the code to run it in the existing set. Even with years of experience never had to use it until today. I like both methods. Thanks so much.
 

Users who are viewing this thread

Back
Top Bottom