Results 1 to 4 of 4
  1. #1
    soli004 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2013
    Posts
    3

    Import multiple txt files acces 2003

    Hello forum,

    I have this code and it is not working for me, the error is like "Can not import this table". What can be wrong?

    I activate the Sub via form with button

    I am a new to access coming from excel so not very experienced user.

    Need this to work as I have 400 txt files all with the same structure

    Thanks




    Code:
    Sub ImportMultipleFiles() 
    Dim strPathFile As String, strFile As String, strPath As String
    Dim strTable As String
    Dim blnHasFieldNames As Boolean
     
    ' Change this next line to True if the first row has Field names
    blnHasFieldNames = True
     
    ' Replace C:\Documents\ with the real path to the folder that
    ' contains the files to import
    strPath = "C:\UA\Imported\"
     
    ' Replace tablename with the real name of the table into which
    ' the data are to be imported
    strTable = "UA_Test"
     
    strFile = Dir(strPath & "*.txt")
    Do While Len(strFile) > 0
    strPathFile = strPath & strFile
    DoCmd.TransferText acImportDelim, strTable, _
    strPathFile, blnHasFieldNames
    
    
     
    strFile = Dir()
    Loop
     
    End Sub

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The syntax for the TransferText command is
    Code:
    DoCmd.TransferText [transfertype][, specificationname], tablename, filename[, hasfieldnames][, HTMLtablename][, codepage]
    You do not have an "specificationname", so you need two commas between the transfer type and the table name.
    Try
    Code:
    DoCmd.TransferText acImportDelim, , strTable, strPathFile, blnHasFieldNames

  3. #3
    soli004 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2013
    Posts
    3
    Thanks, I hope it solve the problem. I will check tomorrow, if not I will upload samplefiles!

    Thanks for the check!

    Regards

    Quote Originally Posted by ssanfu View Post
    The syntax for the TransferText command is
    Code:
    DoCmd.TransferText [transfertype][, specificationname], tablename, filename[, hasfieldnames][, HTMLtablename][, codepage]
    You do not have an "specificationname", so you need two commas between the transfer type and the table name.
    Try
    Code:
    DoCmd.TransferText acImportDelim, , strTable, strPathFile, blnHasFieldNames

  4. #4
    soli004 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2013
    Posts
    3
    That did the work! "," was missing

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Automate Import of Multiple .DBF Files.
    By Robeen in forum Access
    Replies: 8
    Last Post: 10-11-2013, 01:43 PM
  2. Import multiple text files automatically
    By instructorTek in forum Import/Export Data
    Replies: 30
    Last Post: 10-20-2012, 04:50 PM
  3. Import multiple files from one location to new tables
    By shmalex007 in forum Import/Export Data
    Replies: 1
    Last Post: 01-05-2012, 03:49 AM
  4. Acces 2003: Import Form
    By compooper in forum Import/Export Data
    Replies: 4
    Last Post: 06-22-2011, 02:51 PM
  5. Replies: 4
    Last Post: 07-15-2010, 05:58 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums