Export Specification in Microsoft Access

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: Acceess Export Specifications

 When you have created the table or query open it up then select File/Export form the menu bar.

Export Specifications Fixed Width

When the browse box comes up navigate to basically any directory, enter a file name, and choose the Text Files type.

import/export specifications wizard

 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 OK.

Now in code you can use this saved specification in the TransferText command as follows:

txtExportName = ExampleEmployee.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:

import/export specifications wizard

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

New! Download a running example of the Docmd.TransferText method using an export specs file.

Microsoft Office:
MS Access 2003
Access 2007
Access 2010
Access 2013

 

Microsoft Office VBA, MS Access 2003, 2007, 2010, 2013, 2016

Scroll to top