Deleting file in a certain location

petko

Registered User.
Local time
Tomorrow, 00:40
Joined
Jun 9, 2007
Messages
89
Hello everyone,

Could someone give an idea how I could code the followin task?

path and filename is always known - if exists. However existence has to be checked:

If path\filename exists then

delete path\filename

End If

Thanks a lot for any help

petko
 
fileklller = "place.of.file.dot.extension" (ex c:\doc.doc)
if len(dir(fileklller)) <> 0 then
kill fileklller
else
...

I think this is what you need
 
This is just a sample which show's what you requested.

Code:
Sub DeleteFile()
    Dim strInput As String
    strInput = InputBox("Full path and file name:", "File Name Test", "blah")
    If strInput = "" Then End
    If Not Dir(strInput) = "" Then
        Kill strInput
    End If
End Sub

Note: Using the Kill function erases the file completely and thus the file is not recoverable.

Note: I wrote this is in Excel VBA, but it should be identical in Access VBA.
 

Users who are viewing this thread

Back
Top Bottom