• Importing TXT files to ACCESS (Access 2002)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Importing TXT files to ACCESS (Access 2002)

    Author
    Topic
    #447029

    I have a server with hundreds of LOG files.

    All the files are labled: rep~%userid%.txt

    In the Txt file are dozens of lines of Text like so:

    ; 32-bit CRC = A7DE8601

    []
    Computer Name=LAPTOP-L10129
    Logged on User=smithjo9
    Automatic Logon=No
    User is Admin=Yes
    User’s domain=WOPR
    User’s DNS domain=WOPR.USA.NET
    Report date=2007-12-15 09:55:31

    [HardwarePrinters]
    WOPR-001413HPLJ8XPCA=HP LaserJet 8150 Series PCL
    WOPR-001431HPLJ4ZPCA=HP LaserJet 4050 Series PCL
    WOPR-001Q21HPLJ85PCA=HP LaserJet 8150 Series PCL
    WOPR-001S62HPCL46PCA=HP Color LaserJet 4600 PCL 6

    QUESTION:

    How can I use MS Access to:

    1. Look into this folder with hundred’s of TXT files.
    2. Import a select number of lines
    3. Convert them into a table

    Thanks…..

    Viewing 0 reply threads
    Author
    Replies
    • #1088506

      I will answer your questions one by one.
      1. use the dir command to loop thru the “rep*.txt” files in your nominated folder, eg
      sMatch = Dir(“your folder namerep*.txt”, this sMatch to “” if there are no files. else sMatch holds the first file of your match. succesive uses of Dir() gets the next name

      2. Use the Input command to open and read lines from the text file and store them into a table

      3. if you know what you want to extract from the field into a table just use the Mid command to populate a different field in the same table or a differnet table if you desire.

      Hope this helps

      • #1088527

        Just a follow up:

        So I create all this in a macro??

        Or do I create it in queries, then make a all in one macro?

        Thanks

        • #1088536

          No i would do this in VBA, you have far more control

    Viewing 0 reply threads
    Reply To: Importing TXT files to ACCESS (Access 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: