Deletion of a text file fails

  • Thread starter Thread starter T''Kai
  • Start date Start date
T

T''Kai

I have developed a series of steps to deploy new front-ends to my users. Part
of the process involves creating a temporary .txt file (TBR.txt) in the same
directory as the replaced front-end. Once the front-end has been replaced I
attempt to delete the .txt file, but it fails.

The .txt file should be removed on the opening of a special mdb file. This
is where the code fails. However, if I create a form and placed the same code
behind a command button, it delete the .txt file perfectly. No error message
is given when the deletion fails.

Why does this code work behind a command button and not on the open event of
a form?

Here's the code:

strPath = CurrentProject.Path & "\"
strTBR = strPath & "TBR.txt"
If Dir(strTBR) <> "" Then Kill strTBR

Any help would be appreciated. Thank you.
 
Just guessing, but does the .mdb file open the text file and read something
from it when you open the .mdb file? If yes, then the file is locked and
cannot be deleted.
 
Not really. If the file's in use, you have to stop using it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 
Back
Top