We help IT Professionals succeed at work.

DoCmd.TransferText acImportDelim - Specification name

I am having this code to import a file into a table... Problems happen with a Zip code field.. Because first records are numeric, Access assumes that the field is number. When it comes a Canadian postal code, the field errors.

I am thinking that the specification name field can be helpful to define the data structure so as to avoid the errors.

I have no clue for how to do that....
Any help
Comment
Watch Question

Top Expert 2016
Commented:
you have to create the import spec

to create an import specification

1. File>get external data>import
2. select in the File of types box   Text files (*.txt etc..
3. select the file
4. in the import text wizard window select  delimited
5. Click advanced
6. in the import specification window
    type the name of the field in the Field Name column
    (here you can use the field names of the destination table, specify data type,
      check the box Skip if you do not want to import the column)


7 click save as, give the specification a name  <-- this is the specification name that you will use in the command line below


   DoCmd.TransferText acImportFixed, "ImportSpecificationName", "myTableName", "C:\myText.txt", True


Author

Commented:
I appreciate the information... It worked great for me.