Home  Fees/Services  Access Examples  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links

DoCmd Examples - Access VBA
Access Export Specification Wizard

Docmd Macro VB Examples Macro DoCmd Functions

Database Tutorials>DoCmd Examples>Export Specifications

Download Access Database >



DoCmd AddMenu
DoCmd ApplyFilter
DoCmd CancelEvent
DoCmd Close
DoCmd CopyObject
DoCmd DeleteObject
DoCmd FindRecord
DoCmd FindNext
DoCmd GotoControl
DoCmd HourGlass
DoCmd Min/Max/Restore
DoCmd OpenForm
DoCmd OpenQuery
DoCmd OpenReport
DoCmd OutputTo
DoCmd RunSQL
DoCmd SendObject
DoCmd TransferDatabase
DoCmd TransferText

Create Export Specs



Access Export Specifications Wizard 

In Access you can define a file format specification, name that specification, and then use it to automate exporting table or query information to a file in that 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’ 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.

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.

 Click ‘Export All’

 When the Export Text Wizard opens click ‘Advanced’.

Text File Export Specifications

You are now looking at Export Specification wizard.  Here you will define the format for the file that you wish to create. 

Access Export Wizard

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.

Import Specifications Wizard

 Now select ‘Save As…’ , name your specification and click ‘OK’.

Access Output Specifications File

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

txtExportName = “c:\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.

TransferText Specifications

 You will be presented with a list of all the specification that are defined in this database:

CSV Export Specifications

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.





Contact Information

Custom Software Developers
MS Access 2003 2000 2002(XP) 97 All Windows Versions