Solved

Appending data to a CSV file

Posted on 2000-05-09
5
1,078 Views
Last Modified: 2008-03-06
How can append the data collected in a table to a CSV (commar seperated variable) file using VBA.  I know I can open the file itself into Access and add the data to it and save it however this would take sometime.  I was wondering if there was a less time consuming method.

Cheers.

Simon
0
Comment
Question by:SIMONWALLACE
  • 3
5 Comments
 
LVL 2

Expert Comment

by:WonHop
ID: 2793958
Hello Simon
Try using the TransgerText.

DoCmd.TransferText acExportDelim, "Table1", "Output1.Txt", True

WonHop

   
0
 
LVL 54

Accepted Solution

by:
nico5038 earned 50 total points
ID: 2793990
Using a write after opening the file in APPEND mode is the fastest.

The only other way is to create the whole file from the tables if it's still there.

Or just create a new file and append it in Wordpad or Word by inserting the new file at the end. But I think your not waiting for that manual solution.

Nico
0
 
LVL 2

Expert Comment

by:WonHop
ID: 2793992
This is one that I use now.

 strFullPathCSV = "C:\Data\NewCSV.txt"
    DoCmd.TransferText acExportDelim, , "qsel_CSV", strFullPathCSV, True

Hope this helps

WonHop
0
 
LVL 3

Expert Comment

by:davereynolds
ID: 2794579
To WonHop,
From Help: "Microsoft Access creates a new text file when you export data from Microsoft Access. If the file name is the same as the name of an existing text file, Microsoft Access replaces the existing text file."
If Simon wants to append to an existing file, another way will need to be used.
0
 
LVL 2

Expert Comment

by:WonHop
ID: 2794637
Thanks davereynolds.
Could he just create a table in the database that will hold the information he needs.  Run an Append Query to Add the new data to the existing table along with all of the previous information.
Then created the CSV file.

If he does not want to keep it in the current DB.  It can be exported and Appended and kept in a separate database.  Then from there create the CSV file.

All of that could be done with VBA.
Would something like that work?

WonHop
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now