Import text file into access

Posted on 2012-09-07
Last Modified: 2012-09-07
I have a large text file needs to be imported to a table in Access (attached is a sample). The first block has complete rows. The following 3 blocks are the variations. They all start with first, last name and end with Username, Password. Everything in between may or may not be there, or there may be a blank row. Every word that has ":" (Phone:) should be a field name.
Please help, thanks.
Question by:AntiBook
    LVL 39

    Expert Comment

    Every word that has ":" (Phone:) should be a field name
    Do you have full list of possible fields? If answer - no, there are following possible solutions:
    1. In first pass collect all possible field names, create table and import data
    2. Write data into 3 tables: First: UserID (autonumber), First and Last name, UserName, Password; Second - Table with possible fields (FIeldID, FieldName): Cod, Phone, etc.; Third with data: UserID, FieldID, Value.
    Do you need strings without ":"?

    Author Comment

    the first block is the complete list of possible fields. So, "COD:", Phone:", "Username:", "Password:" are field names. They don't need to be imported, but the data after ":" needs to be imported. The rest of the rows don't have field names. You can name them whatever, and the whole row needs to be imported. Can you give me the vba code to do that? thanks
    LVL 39

    Accepted Solution

    Test this

    Author Closing Comment

    thanks again

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now