Deleting Source Data after Import

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using Access 2000 to import bank data every day using a simple macro run
through a switchboard. In order to prevent the user from accidentally
clicking the switchboard button twice or otherwise importing the same data
multiple times, I'd like to have Access simply delete the contents in the
source file, bankdata.txt, after the import is complete.

I would just use the Kill command in VBA to delete the file, but I would
prefer to have the empty file called bankdata.txt available to ensure that
the user saves the file (downloaded using Internet Explorer) with the correct
filename.

Is there an easy wasy to do this? Thanks!
 
You can overwrite a file with an empty one of the same name by using
something like this, assuming the path to the file is in strFileSpec:

Dim lngFN As Long

lngFN = FreeFile()
Open strFileSpec for Output as #lngFN
Close #lngFN
 
Works like a charm. Thanks for your help, John!

John Nurick said:
You can overwrite a file with an empty one of the same name by using
something like this, assuming the path to the file is in strFileSpec:

Dim lngFN As Long

lngFN = FreeFile()
Open strFileSpec for Output as #lngFN
Close #lngFN
 
Back
Top