clear up the content but not the file

T

Tim

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.
 
J

John Nurick

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?
 
T

Tim

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top