Microsoft KB Archive/241477

= ACC2000: Error When You Try to Use Schema.ini to Import or Export with the TransferText Method =

Article ID: 241477

Article Last Modified on 12/12/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q241477





This article applies only to a Microsoft Access database (.mdb).

Advanced: Requires expert coding, interoperability, and multiuser skills.



SYMPTOMS
When you use the TransferText method to import or export a text file, you may receive the following error message:

Run-time error '2511':

The action or method requires a Specification Name argument.

-or-

Run-time error '3625':

The text file specification ' ' does not exist. You cannot import, export, or link using the specification.



RESOLUTION
Use the Data Access Object (DAO) Execute method to import the text file. You can instruct this method to use the Text ISAM driver. This driver is designed to automatically use a Schema.ini file, as long as the file resides in the same folder as the text file. Sub ImportSchemaTable Dim db As DAO.Database Set db = CurrentDb db.Execute _ "SELECT * INTO NewContact FROM [Text;FMT=Delimited;HDR=Yes;DATABASE=C:\My documents;].[Contacts#txt];", _ dbFailOnError db.TableDefs.Refresh End Sub



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The TransferText method carries out the TransferText action in Visual Basic. The syntax for this method is: DoCmd.TransferText [TransferType][, SpecificationName], TableName, FileName[, HasFieldNames][, HtmlTableName][, CodePage] The SpecificationName argument of the TransferText method is a string expression that is the name of an import or export specification that you have created and saved in the current database.

Access 2000 Help states that when you use the SpecificationName argument for a fixed-width text file, you must either specify an argument or use a Schema.ini file, which must be stored in the same folder as the imported, linked, or exported text file. However, when you apply these instructions, you can encounter one of the error messages listed in the "Symptoms" section.

Steps to Reproduce the Behavior
  Start NotePad, and type the following text. Then, save the file as C:\My Documents\Contacts.txt: First    NameLast NameHireDate Nancy    Davolio  10-22-91 Robert   King     10-23-91   On the File menu, click New, and then type the following text. Then, save the file as C:\My Documents\Schema.ini: [Contacts.txt] ColNameHeader=True Format=FixedLength MaxScanRows=0 CharacterSet=OEM Col1="First Name" Char Width 10 Col2="Last Name" Char Width 9 Col3="HireDate" Date Width 8 NOTE: Make sure that both the Contacts.txt file and the Schema.ini file are stored in the C:\My Documents folder.

  : Make sure that both the Contacts.txt file and the Schema.ini file are stored in the C:\My Documents folder.Open a new database, create a new module, and add the following code: Sub Test1 DoCmd.TransferText acImportFixed,, "Contacts", "C:\My Documents\Contacts.txt" End Sub  : Make sure that both the Contacts.txt file and the Schema.ini file are stored in the C:\My Documents folder.In the Immediate window, type Test1, and then press ENTER. Note that you receive one of the errors that is mentioned in the "Symptoms" section.</li>  : Make sure that both the Contacts.txt file and the Schema.ini file are stored in the C:\My Documents folder.Add the following code to your module: Sub Test2 DoCmd.TransferText acImportFixed, "C:\My Documents\Schema.ini", "Contacts", "C:\My Documents\Contacts.txt" End Sub </li> : Make sure that both the Contacts.txt file and the Schema.ini file are stored in the C:\My Documents folder.In the Immediate window, type Test2, and then press ENTER. Note that you receive one of the errors that is mentioned in the "Symptoms" section.</li></ol>

<div class="references_section">