Docmd.TransferText Action & Method Example
The TransferText method is used to import/export text between
the current Access database or Access project and a text file located externally
to your database. You can also use this command to link to data in a text file.
Additionally, can import from, export to, and link to a table in an HTML file.
However, linking to text or HTML file data will result in a read only dataset.
The TransferText method has the following syntax and options:
DoCmd.TransferText(TransferType, SpecificationName, TableName,
FileName, HasFieldNames, HTMLTableName, CodePage)
Transfer Type is the type of transfer you want to perform. You can
import, export, or link to data in text files or HTML files. You can also export
data to an MS Word mail merge file.
Specification Name The specification name for the set of options that
determines how a text file is imported, exported, or linked. For a fixed-width
text file, you must either specify a specification name or use a schema.ini
file, which should be stored in the same directory as the imported, linked, or
exported text file.
To learn more about creating an export or import specification
file see our detailed example titled
Access Export Specification Wizard.
Table Name The name of the table to import text data to, export text data
from, or link text data to. You may also export data from a query.
Enter the query name in the table name option.
File Name (required) This is the name of the file to import from, export
to, or link to. Don't forget to specify the full path for the file.
Access will create a new file if non exists or will over write
an existing file.
Note that if you want to import or link a particular table or list in an HTML
file, you can use the HTML Table Name argument.
Has Field Names This option specifies whether the first row of the file
contains the names of the data fields. If you select Yes, then Access uses the
names in this row as field names in the Access imported/linked table. If
you select No, Access treats the first row as a normal row of data. The default
value for this option is No.
Note that for Word mail merge data files this option is ignored
because the first row must contain the field names.
HTML Table Name The name of a table or a list in the HTML file that you
intend to import or link to. This argument is only used when the Transfer Type
option is set to Import HTML or Link to HTML. The default for this field is to
import the 1st table or list in the HTML file.
Note that you must use the <Caption> tag in the HTML file to
name the table or list.
Code Page is the name of the character set used with the code page.