Link to home
Create AccountLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

Using Access 2003 with an MDB type file, how would you export an Access file to a txt file ?

I am developing an Access application using Access 2003 with an MDB type file.
If I have an Access table named tblNameAddress and it is comprised of 3 fields as follows:

1) FieldA   type TEXT    length 5       positions 1 to 5
2) FieldB   type TEXT    length 10     positions 6 to 15
3) FieldC   type TEXT    length 5       positions 16 to 20

How would you export this Access table tblNameAddress to a txt file named C:\NameAdd.txt ?

Avatar of Jim Horn
Jim Horn
Flag of United States of America image

This sounds real bass-ackwards, but here's how you do it:

(1)  Create a mock-up of your text file.
(2)  In Access, File: Get External Data: Import...
(3)  In the 'Windows Common File Open' dialog that appears, change the 'Files Of Type' to text
(4)  Select your Text file
(5)  The 'Import text Wizard' will appear.  Hit the Advanced button, create an import spec (follow the instructions), and SAVE IT, and remember the name.

Now that you created the Import Spec, you can export using the below line of VBA code:
docmd.TransferText acExportFixed, "Your Import Spec Name", "tblNameAddress", "C:\NameAdd.txt"
Avatar of zimmer9


Once you have Saved an Import Spec is there a way to go back into it at a later date to make revisions to it. If so, how to you navigate back to the existing Import Spec ?
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Jeanniem

Also, when I change F:\Numbers to F:\Numbers.txt I get a runtime 3011 "can not find object "Numbers#txt"