How do you delete an external file

  • Thread starter Thread starter Bre-x
  • Start date Start date
B

Bre-x

Hi,

How do you delete an external file using VBA on MS Access 2000?

Dim fso As New Scripting.FileSystemObject
fso.DeleteFile (Application.CurrentProject & "\VR_Server.mdb")

Thank you all

Bre-x
 
You could try to kill it. From Access Help:
This example uses the Kill statement to delete a file from
a disk.
' Assume TESTFILE is a file containing some data.
Kill "C:\Path\TestFile"

' In Microsoft Windows:
' Delete all *.TXT files in current directory.
Kill "*.TXT"
 
but beware --
Kill throws an error if the file does NOT exist.
You need to either:
1) test for its existence and conditionally kill, or,
2) wrap the kill in an On Error Resume Next handler
-=-=
 
Back
Top