Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Importing TXT files to ACCESS (Access 2002)

    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.....

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Importing TXT files to ACCESS (Access 2002)

    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

  3. #3
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Importing TXT files to ACCESS (Access 2002)

    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

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Importing TXT files to ACCESS (Access 2002)

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

Posting Permissions

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