If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Problem deleting a .txt file
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. 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. |
#2
|
|||
|
|||
Problem deleting a .txt file
T''Kai wrote:
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. What error message do you get when the code runs in the form's open event? |
#3
|
|||
|
|||
Problem deleting a .txt file
No error message. It just does nothing.
"Gigamite" wrote: T''Kai wrote: 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. What error message do you get when the code runs in the form's open event? |
#4
|
|||
|
|||
Problem deleting a .txt file
T''Kai wrote:
No error message. It just does nothing. That shouldn't happen unless system messages are turned off. Look in the code and macros for SetWarnings. Do you have any? The practice of turning system messages on and off should be avoided, but it's fairly common in Access databases. The code may be failing in the form open event because the text file is still locked from another process. You may have to put a slight time delay in before running the file delete code. |
#5
|
|||
|
|||
Problem deleting a .txt file
I will try the time delay. Strangely, I have found that if I put the text
file into a seperate folder and still read it as I have been, I can delete it from this new folder. The problem then becomes deleting the folder. "Gigamite" wrote: T''Kai wrote: No error message. It just does nothing. That shouldn't happen unless system messages are turned off. Look in the code and macros for SetWarnings. Do you have any? The practice of turning system messages on and off should be avoided, but it's fairly common in Access databases. The code may be failing in the form open event because the text file is still locked from another process. You may have to put a slight time delay in before running the file delete code. |
#6
|
|||
|
|||
Problem deleting a .txt file
T''Kai wrote:
I have found that if I put the text file into a seperate folder and still read it as I have been, I can delete it from this new folder. The problem then becomes deleting the folder. What's the problem? Another silent failure when deleting the folder? |
#7
|
|||
|
|||
Problem deleting a .txt file
Yes, but I think this may be because it thinks the folder is in use. Any
suggestions. "Gigamite" wrote: T''Kai wrote: I have found that if I put the text file into a seperate folder and still read it as I have been, I can delete it from this new folder. The problem then becomes deleting the folder. What's the problem? Another silent failure when deleting the folder? |
Thread Tools | |
Display Modes | |
|
|