7.5. Text Files

The TransferText method allows you to import from, link to, and export to text files. It has the following syntax:

DoCmd.TransferText TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage

As you would expect, various parameters can be used to specify how the method should execute. These parameters are similar to the TransferDatabase and TransferSpreadsheet methods you have already seen. The following table explains the use of each parameter.

Figure 7.3. Figure 7-3
ParameterDescription
TransferTypeType of transfer to be performed. The default is acImportDelim. See the Access help documentation for a complete list and explanation.
SpecificationNameName of import or export specification you have saved in the current database. This argument can be left blank for text files that are delimited with certain characters or spacing to indicate the location of the fields. The example text file in the next section is a comma-delimited file.
TableNameString expression that contains a table name you want to work with or a query you want to export.
FileNameFile name and path of the text file you want to work with.
HasFieldNamesUse True to use the contents of first row of the spreadsheet as field names and False to treat the first row as data. False is the default.
HTMLTableNameUse with acImportHTML or acLinkHTML. Name of table or list in HTML ...

Get Beginning Access™ 2007 VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.