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
 

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

Back
Top