Deletion of a text file fails

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

Ken Snell [MVP]

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

Douglas J. Steele

Not really. If the file's in use, you have to stop using it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 

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

Top