A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Problem deleting a .txt file



 
 
Thread Tools Display Modes
  #1  
Old July 2nd, 2009, 01:16 AM posted to microsoft.public.access
T''Kai
external usenet poster
 
Posts: 25
Default 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  
Old July 2nd, 2009, 07:04 AM posted to microsoft.public.access
Gigamite[_2_]
external usenet poster
 
Posts: 27
Default 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  
Old July 2nd, 2009, 03:42 PM posted to microsoft.public.access
T''Kai
external usenet poster
 
Posts: 25
Default 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  
Old July 3rd, 2009, 07:43 AM posted to microsoft.public.access
Gigamite[_2_]
external usenet poster
 
Posts: 27
Default 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  
Old July 3rd, 2009, 03:51 PM posted to microsoft.public.access
T''Kai
external usenet poster
 
Posts: 25
Default 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  
Old July 3rd, 2009, 09:47 PM posted to microsoft.public.access
Gigamite[_2_]
external usenet poster
 
Posts: 27
Default 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  
Old July 4th, 2009, 05:20 AM posted to microsoft.public.access
T''Kai
external usenet poster
 
Posts: 25
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.