|
#1
|
|||
|
|||
|
Hi All,
My program is a questionnair where the user simply enters data like Title, Firstname, Surname etc. Once the user clicks on SAVE it outputs the data to a txt file. The way it should work is each time a user clicks on SAVE, if the file "C:\Test1.txt" already exists, the file name is changed by inserting the SYS data/time, and a new text file is created "Test1.txt", which has all the previous data plus the new data just inputted by the user i.e. the most up-to-date version file. The problem i am having is if the file exists and after it has renamed the file with SYS DATE/TIME, when creating the new "Test1.txt" file will ALL THE PREVIOUS data is lost and it simply displays the new data the user had just inputted. Code:
If retval = fileName Then
MsgBox "file already exists", vbCritical
Name "c:\Test1.txt" As "c:\Test1_OLD_" & Format(Now, "yyyy-mm-dd HhNn") & ".txt"
End If
Open "C:\Test1.txt" For Append As #1
Write #1, txtTitle, txtFirstname, txtSurname
Close #1
__________________
Thankyou |
|
#2
|
||||
|
||||
|
if you rename the file, the original file is lost and thus there is nothing to append to.
Use CopyFile instead of Name But sincerely, I do not see any reason to keep an old version of the file if you are just appending data to it. The previous file is just the new one less the last line... Marco
__________________
"There are two ways to write error-free programs. Only the third one works." Unknown |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Save a file using client-side javascript | Anjana | Web | 5 | 05-27-2008 12:17 PM |
| Loading data from a file to text boxs | mike_w | VB Classic | 2 | 05-22-2005 12:04 PM |
| Importing data.. sigh | Dana | Database | 3 | 10-09-2000 06:13 PM |
| Creating a form that saves to a txt file | vale | ASP.NET | 1 | 08-23-2000 08:36 PM |
| DTS - deleting a text file after importing the data... | Paul | Database | 0 | 08-22-2000 11:54 PM |