Access Export Specifications
File export specifications are create in MS Access using a
wizard. You can define a file export format specification, name that
specification, and then use it to automate exporting table or query information
to a file in specified format.
Use the export specification
wizard to create the specifications for the DoCmd.TransferText macro and
visual basic function.
Finding your way to the specifications is one of Access's
more obscure features.
First create the table or query that you wish to export.
Our example is a simple Employee table:
When you have created the table or query open it up then
select File/Export form the menu bar.
When the browse box comes up navigate to basically any
directory, enter a file name, and choose the Text Files type.
Click Export All
When the Export Text Wizard opens click Advanced
You are now looking at Export Specification wizard. Here
you will define the format for the file that you wish to create.
The default is a comma delimited file. For this example I
am going to select Fixed Width. You can see that it fills in the start and
length values based on the table definition.
Now select Save As, name your specification and click
Now in code you can use this saved specification in the
TransferText command as follows:
txtExportName = \Example\Employee.txt"
DoCmd.TransferText acExportFixed, "Employee Export
Specification", "Employee", txtExportName
The command above is saying use the format in the
Employee Export Specification specification on the data in table Employee to
create the file named in variable txtExportName.
The result is this simple text file:
Now if you ever need to go back and modify that
specification you have to take the long road to get there. Basically act like
you are starting all over again to create a specification but when you get to
the Export Specification wizard click the Specs button.
You will be presented with a list of all the specification
that are defined in this database:
Select the one you want and click Open. You are now back
at the specification you defined and saved originally. Modify away!
Contributed By: Janet Loch