How do I specify a field type when importing a text file? (One)
problem:
I have a text file to import Access, but a column of data is originally text, but the import database is automatically turned into a "double precision" type. How can I let each field generate according to the data type I need? How to let Access import data from text files, specifications from the architecture of I specified?
method one:
Access itself has an imported export wizard, which can be customized to import data in detail in the advanced option. The steps are as follows:
Menu -> File -> Get External Data -> Import (or "Link Table") -> Select You Required Format Document -> Advanced Menu -> File -> Get External Data -> Import (or "Link Table ") The picture is as follows: Choose the image you need to have the following: Click the" Advanced "button to the following: Define field specifications in Import Specifications, press" Save "button after the definition is complete, select the appropriate specification name As follows: Definition After the Field Specification is stored in MSYSIMEXCOLUMNS and the MSYSIMEXSPECS table below: After completing the above operation, you can use the following statement to link or import text files.
DOCMD.TRANSFERTEXT AclinkDelim, "List1 Import Specifications", "List1", "C: /List1.txt" DOCMD.TRANSFERTEXT ACIMPORTDELIM, "List1 Import Specifications", "List1", "C: /List1.txt" About TRANSFERTEXT method Refer to the following information (taken from Access XP Help)
TransferText Method In Visual Basic, the Transfertext method performs Transfertext operations. Expression.Transfertext (Transfertype, Specificationname, TableName, FileName, HasfieldNames, HTMLTABLENAME, CODEPAGE) Expression is required. Returns the expression of an object in the "Applies to" list. TRANSFERTYPE Optional ACTEXTTRANSFERTYPE. AcTextTransferType AcTextTransferType constants can be one of the following: acExportDelim acExportFixed acExportHTML acExportMerge acImportDelim default acImportFixed acImportHTML acLinkDelim acLinkFixed acLinkHTML If this parameter is blank, then the default constant (acImportDelim). Note You can link to the text file or the data in the HTML file, but the data is read-only in Microsoft Access. In the Microsoft Access project (Microsoft Access Project: Connect to the Microsoft SQL Server Database and use to create an Access file for the client / server application. There is no data or data-defined objects (such as tables or views) in the project file. ACIMPORTDELIM, AcimportFixed, AcexportDelim, AcexportFixed, or ACEXPORTMERGE conversion types are supported in .adp). SpecificationName Optional Variant type. String expressions (string expressions: any expression of a row of consecutive characters. Elements of expression can include: Returning string or string Variant (VARTYPE 8) function; string string value, constant, Variables or variant.), Indicating the names of imported or export specifications created and saved in the current database. For a fixed length text file, you must specify parameters or use the schema.ini file, which must be saved in the same folder of the imported, link, or export file file. To create a schema file, you can create this file using the Text Import / Export Wizard. For separate text files and Microsoft Word mail merge data files, this parameter can be left blank to select the default import / export specification. TableName Optional Variant type. String expression, indicating the name of the Microsoft Access table to import text data, export text data or link text data, or derived its results to Microsoft Access Query (Query: About the data stored in the table) Problem, or request to execute the data execution operation. The query can be placed together in multiple tables as a name of the data source.) From the data source.). FileName Optional Variant type. String expressions indicate the full name (including path) of the text file to be imported, exported or linked. HasfieldNames optional Variant type. Using true (-1) can use the first line of the text file as a field name when importing, exporting, or linked. Use false (0) to see the first line in the text file as normal data. If this parameter is left blank, the default value is used. This parameter will be ignored by Microsoft Word Mail Merge Data file, and the field name must be included in the first row of these files. HTMLTABLENAM optional Variant type.
String expressions, indicating the names of the table or list in the HTML file to import or link. This parameter will be ignored unless the Transfertype parameter is set to Ac1rthtml or AclinkHTML. If you leave this parameter, the first table or list in the HTML file is imported or linked. If there is a