Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

Delete existing before running Open "c:\MyFile.txt" For Output As #1 ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MLH - 13 Dec 2005 17:10 GMT
Is it good programming practice to delete existing file before running
Open "c:\MyFile.txt" For Output As #1 ???

IE, I already have a file c:\MyFile.txt on disk and I launch
Open "c:\MyFile.txt" For Output As #1  ==>  VBA is supposed to
overwrite whatever WAS there with the new contents - right? And
if that is true, does it matter whether I delete the existing file
prior to running the Open statement?
Danny J. Lesandrini - 13 Dec 2005 18:01 GMT
I generally like to clean up, either before a process or after it ends,
for files that are disposable.  Try something like this ...

   If Dir("c:\MyFile.txt") <> "" Then Kill("c:\MyFile.txt")

Signature

Danny J. Lesandrini
dlesandrini@hotmail.com
http://amazecreations.com/datafast

> Is it good programming practice to delete existing file before running
> Open "c:\MyFile.txt" For Output As #1 ???
[quoted text clipped - 4 lines]
> if that is true, does it matter whether I delete the existing file
> prior to running the Open statement?
MLH - 13 Dec 2005 18:28 GMT
>I generally like to clean up, either before a process or after it ends,
>for files that are disposable.  Try something like this ...
>
>    If Dir("c:\MyFile.txt") <> "" Then Kill("c:\MyFile.txt")
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yep. That's good practice.
Douglas J. Steele - 13 Dec 2005 19:01 GMT
Opening a file As #1 isn't good programming practice!

Dim intFile As Integer

  If Len(Dir("c:\MyFile.txt")) > 0 Then
     Kill "c:\MyFile.txt"
  End If

  intFile = FreeFile()
  Open "c:\MyFile.txt" For Output As #intFile

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Is it good programming practice to delete existing file before running
> Open "c:\MyFile.txt" For Output As #1 ???
[quoted text clipped - 4 lines]
> if that is true, does it matter whether I delete the existing file
> prior to running the Open statement?
MLH - 14 Dec 2005 03:36 GMT
Good point. I agree.
xxxxxxxxxxxxxxxxxxxxxxxxxx
>Opening a file As #1 isn't good programming practice!
>
[quoted text clipped - 6 lines]
>   intFile = FreeFile()
>   Open "c:\MyFile.txt" For Output As #intFile
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.