TransferText Method

Applies To

DoCmd Object.

Description

The TransferText method carries out the TransferText action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.TransferText [transfertype] [, specificationname], tablename, filename[, hasfieldnames]

The TransferText method uses the following arguments.

Argument

Description

transfertype

One of the following intrinsic constants:

acImportDelim
acImportFixed
acExportDelim
acExportFixed
acExportMerge
acLinkDelim
acLinkFixed

If you leave this argument blank, the default (acImportDelim) is assumed.

specificationname

A string expression that is the name of an import or export specification you have created and saved in the current database.

This argument is required for fixed-width text files. For delimited text files and Microsoft Word for Windows mail merge data files, you can leave this argument blank to select the default import/export specifications.

tablename

A string expression that is the name of the Microsoft Access table you want to import text data to, export text data from, or link text data to, or the Microsoft Access select query whose results you want to export to a text file.

filename

A string expression that is the full name, including the path, of the text file you want to import from, export to, or link to.

hasfieldnames

Use True (-1) to use the first row of the text file as field names when importing, exporting, or linking. Use False (0) to treat the first row of the text file as normal data. If you leave this argument blank, the default (False) is assumed.

This argument is ignored for Word for Windows mail merge data files, which must always contain the field names in the first row.


Remarks

You can leave an optional argument blank in the middle of the syntax, but you must include the argument’s comma. If you leave a trailing argument blank, don’t use a comma following the last argument you specify.

See Also

DoCmd Object, OutputTo Method, SendObject Method, TransferDatabase Method, TransferSpreadsheet Method, TransferText Action.

Example

This example exports the data from the Microsoft Access table External Report to the delimited text file April.doc using the specification Standard Output.


DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "C:\Txtfiles\April.doc"