Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB/VBA to export Access tables to fixed width text files

Status
Not open for further replies.

KrazyKT

Programmer
Jul 5, 2000
26
0
0
US
I have Access files with four tables each. I need a faster way to use code to pull the file in a certain directory and export the tables as text. The four tables with the Access files have same structures and names. I know this can be done, I just don't have the experience behind me to help me do this.

KT [sig][/sig]
 
The following code will work to run an export of a table to a text file:
Code:
Public Function ExportTextFile()
   DoCmd.TransferText acExportFixed,     _
                      "TestExport",      _
                      "tblEmployees",    _ 
                      "H:\Temp\Test.txt"
End Function
Before you can use it, you need to create the Export Specification manually. (File Menu->Save as/Export-> To external file->Change file type to text file->Export-> Advanced Button, Save Specification)

The help does have this final note to say about the way I coded it:

Note: Although you can use the TransferText method in Visual Basic to link to text data, it's recommended that you use Data Access Objects (DAO) instead. To create a link by using DAO, use the Connect property for the TableDef object.

Hope this helps...
[sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top