Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to delete Excel file after importing into Access

Status
Not open for further replies.

sharkatek

Programmer
Mar 11, 2005
51
0
0
1 - I am able to successfully import an Excel file into my Access table, but I need to delete the Excel file after importing - how can I do this with VBA?

2 - When I display the "Import" form, I want to enable import buttons when a new Excel file has been created (by another process) and is detected - How can I test to see if a file is there before enabling a button on a form? And should the code go into the form load or form open?

thank-you in advance!
Sharkatek
 
Have a look at the Kill instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Be careful with this as the 2003 Access sandbox does not allow the kill statement.

Want the best answers? See FAQ181-2886

 
ok - thank-you! I am currently using Access 2000, but what if I upgrade later? Is there code that can be used with Access 2000 that is compatible with later versions to:

1 - detect the existence of an .xls file
(and if I wanted to make a form's buttons enabled or disabled based on this, would my code go in the Form Open or Form Load - I need an answer to this either way)?

2 - DELETE the file (it is not a write protected file)

 
This is tricky, I do know that the Kill function fails in 2003 I have changed a database that used this and now use a connection to the file instead of deleting then creating a fresh one. Though this is an access file so would not help you. It was one of my customers who upgraded not I so it did leave me with egg on my face tbh. Still resolved now.

Actually Kill is technically not supported in 2000 it is a legacy command from previous versions of VBA (a bit like ERL) but I have never seen an alternative and as it worked I stuck with it.

I'd detect the presence of the file in the Form_open and enable/disable the buttons there.

Want the best answers? See FAQ181-2886

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top