Solved

Appending data to a CSV file

Posted on 2000-05-09
5
1,077 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

762 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