checking for file

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

Larry Linson

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
 
K

Klatuu

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
 
B

Bill H.

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
 
Top