clear up the content but not the file

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

Guest

Hi,
Do you know how to clear up the content but not the file?? I know how to
delete the file on the c:\ drive using the following code in the Access
module,
Kill "C:\filename.dat"

But I can not use it because it kills the whole file. I just need to clear
this file up. Pls help.
Thanks, T.
 
Hi Tim,

AFAIK with Windows file systems the simplest thing is to replace the file
with a zero-length one of the same name, e.g. along these lines:

Public Sub EmptyFile(FileSpec As String)
Dim lngFN as Long

Kill strFileSpec
lngFN = FreeFile()
Open strFileSpec For Output As #lngFN
Close #lngFN
End Sub

But a zero-length file isn't seldom any use to man or beast: what's the
problem you're trying to solve?
 
Hi John,
Thank you for your help. It works! The way I do is I want to clear up the
..dat file and then save a new .dat file in to be manipulated by Access VBA.
Since the program requires that .dat name so I have to keep the name. I know
it's weird but that the way it is.
Thank you again, Tim
 
Back
Top