Results 1 to 5 of 5
  1. #1
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071

    Importing Text files

    I have a project that requires me to import about 25 Text files into an access Database and parse out the lines of text using a non-standard field separator. I'm building the code to parse the lines but since there's multiple files I'd like to read in the filenames from the directory and loop through doing all of the files in 1 run of the code. I'm using MS Access 2010. Anybody have any ideas?

  2. #2
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    What code have you got so far?

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    When you import the 1st text file, you should be able to save the field mappings, so when you go to import the 2nd text file, all you would have to do is use the same mappings for the 1st. Assuming they are all in the same format.

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Found the code I needed in one of my Access Programming books.

    this is what I used and it works.

    Dim sqlfilename As String, ff As Long, fs As Variant
    Dim sourcefolder As Variant, currfile As Variant, lngend As Long
    Dim lngstart As Long, PID(1 To 12) As String, lngctr As Long
    Dim strline As String, strfilename As String, sfilename As String
    ff = FreeFile()
    Set fs = CreateObject("scripting.filesystemobject")
    Set sourcefolder = fs.getfolder(HL72010Path)
    For Each currfile In sourcefolder.files
    strfilename = HL72010Path & currfile.Name
    Open strfilename For Input As #ff
    Line Input #ff, strline
    lngstart = 0

  5. #5
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Good for you!

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

Similar Threads

  1. Importing files into Access 2007
    By rjani1 in forum Access
    Replies: 6
    Last Post: 07-19-2011, 09:33 AM
  2. Replies: 1
    Last Post: 11-05-2010, 04:31 PM
  3. importing Dbase files
    By dzawicki in forum Import/Export Data
    Replies: 2
    Last Post: 01-14-2010, 05:43 PM
  4. Importing multiple files at once
    By NoiCe in forum Import/Export Data
    Replies: 1
    Last Post: 04-01-2009, 10:10 AM
  5. Importing Xls and CSV files into MS Access
    By Jeff in forum Import/Export Data
    Replies: 1
    Last Post: 02-17-2009, 11:56 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