Export Tables to Text Files

I am trying to export multiple tables to text files.  I have a lookup table for names and an export specification.  Do you please have generic VBA code which I may use to perform this task?
LVL 1
CFMIFinancial Systems AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
DoCmd.TransferText will allow you to do this. I have no idea what you mean by "lookup table for names", but if you mean that you have a table that holds the names of the Tables you want to export, along with the specs, then do this:

Dim rst As DAO.Recordset
Set rst = Currentdb.Openrecordset("SELECT * FROM YourTable")

DO Until rst.EOF
  DoCmd.TransferText acExportDelimited,  rst("YourSpecField"), rst("TableName"), <Your File Path>
  rst.MoveNext
Loop

Obviously you'd have to change the Table and Field names to match your own, and also provide a valid value for <YourFilePath>

See this MSDN article for more info on the syntax: https://msdn.microsoft.com/en-us/library/office/ff835958.aspx?f=255&MSPPError=-2147217396
FlysterCommented:
You can use DoCmd.OutputTo acOutputTable:
Function TableToText()

DoCmd.OutputTo acOutputTable, "YourTableNameHere", "MS-DOSText(*.txt)", "C:\DocumentPathHere\DocumentNameHere", , , , acExportQualityScreen

End Function

Open in new window

Flyster
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
OutputTo doesn't include any method to use an Export Spec, however.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CFMIFinancial Systems AnalystAuthor Commented:
Thanks guys.  I'll digest this and create new if need be.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.