Results 1 to 5 of 5
  1. #1
    rtackett is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    1

    Transfer all text files in a specified folder

    I need assistance transferring all text files (fixed width) into my database. I created this code for excel files and it works great but am unsure how to do it for the text files. Any assistance would be greatly appreciated.

    Private Sub Command1_Click()

    Dim strPathFile As String, strFile As String, strPath As String


    Dim strTable As String, strBrowseMsg As String
    Dim blnHasFieldNames As Boolean

    blnHasFieldNames = False
    strBrowseMsg = "Select the folder that contains the EXCEL files:"
    strPath = "C:\Users\IA User 1\Desktop\PRODUCTIVITY"
    If strPath = "" Then
    MsgBox "No folder was selected.", vbOK, "No Selection"
    Exit Sub
    End If

    strTable = "IMPORT ARCHIVEDATA"
    strFile = Dir(strPath & "\*.xls")
    Do While Len(strFile) > 0
    strPathFile = strPath & "\" & strFile
    DoCmd.TransferText acImprotFixed - HERE IS WHERE I TRIED TO CHANGE IT TO NO AVAIL!
    strTable , strPathFile, blnHasFieldNames
    Kill strPathFile
    strFile = Dir()
    Loop
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why - error message, wrong results, nothing happens?

    You show a misspelling of acImportFixed. How could that happen?

    Need to change .xls to .txt or .csv, whichever your text files are.

    Review link on dubugging techniques at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Do you have 2 usernames here or a twin? Seems to the same issue here
    https://www.accessforums.net/import-...les-27936.html

    Strange that the problems are.....

  5. #5
    raytackettsells is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    27
    Quote Originally Posted by orange View Post
    Please review the TransferText method and syntax

    http://msdn.microsoft.com/en-us/libr.../ff835958.aspx
    I have everything figured out with the exception of the path which I want it to transfer all text files in the specified folder, not just a single file.

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

Similar Threads

  1. Transfer text files
    By raytackettsells in forum Import/Export Data
    Replies: 5
    Last Post: 09-08-2012, 12:37 PM
  2. Number of files in a folder.
    By Iain in forum Reports
    Replies: 3
    Last Post: 06-17-2012, 01:53 PM
  3. Replies: 13
    Last Post: 05-23-2012, 12:30 AM
  4. Copy files into specific folder
    By Jan22 in forum Access
    Replies: 12
    Last Post: 04-17-2012, 08:27 AM
  5. Replies: 2
    Last Post: 10-26-2011, 02:48 PM

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