O'Reilly logo

Beginning Access™ 2007 VBA by Denise Gosnell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required