checking for file

  • Thread starter Thread starter Bill H.
  • Start date Start date
B

Bill H.

How do i use vba (access) to check for the existance of a file on the hard
disk, and then if there, to delete it?

I can't seem to quite get the syntax.

Thanks.
 
Use the Kill statement to delete it, and include error handling code to
field the error if it is not there. That is the simplest way.

Larry Linson
Microsoft Access MVP
 
Assume strTheFile is the full path and file name of the file you want to
delete:

If Dir(strTheFile) = "" Then
MsgBox "File Not Found"
Else
Kill strTheFile
End If
 
that seems to work.

Thanks!

Klatuu said:
Assume strTheFile is the full path and file name of the file you want to
delete:

If Dir(strTheFile) = "" Then
MsgBox "File Not Found"
Else
Kill strTheFile
End If
 
Back
Top