Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    6

    Unanswered: Importing Text File Inot Access XP

    Lets say I have multiple text files that look like this:
    name:nt
    address:12345
    city:beverlyhills
    state:ca
    age:99

    the data within text file is not comma separated, nor is it tab but is in a verticle arrangment such as the example above.

    Question: how do I import data like this into a table in Access XP whereas the data is in columns like this:
    name address city state age

    Your help is appreciated, thanks.

    ntbluez

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    This is kind of like working with XML with the end tags missing. In VBA, I would read the file line by line and check out what was up to the colon. The data after the colon would get stored into the appropriate variable and next time it hit a Name, I would write the record to the database, clear the variables and continue with the next record.

    If name isn't always the first line or some colons are missing, then this will not work. You would have to trap those errors.

    Skills required:
    - know how to use vba
    - know how to read line by line from a text file
    - know how to use instr to find the colon
    - know how to use mid to extract data after the colon
    - know how to insert into a recordset or run an insert query from code

    If you need help with any of the above, and help is not helpful enough, let us know where you got stuck. I hope this is a one time job...

    Good luck!

  3. #3
    Join Date
    Oct 2003
    Posts
    24

    is it...

    is it separated by colons as in your example ?

    kevin

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    * Try to read line by line, searching the [:] or any other char. that is in
    every line and separates the Field Name form the Data, then you will
    be able to read the Field names, the data, number of Records and
    store them

    * Write the Field Names

    * In another loop you can write your data separated with any separator.





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •