Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Cool Unanswered: Searching Directories and import files

    Hi,

    I need to search a directory on a server the dir is split up into days of the month (eg. //2004/02/01 ect for everyday in the month). In each directory there are about 20 text files with different names that each needs to go into its own table in access. So the ideal will be to enter a directory and for every file thats imported put a flag in the database, so that you can say import //2004/02 and will then scan through all 30 dirs and import all the files.

    I am completely new to Access and VB, and don't even now where to start - any help will be appreciated.

    Thanks.

  2. #2
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: Searching Directories and import files

    Originally posted by neetie
    I am completely new to Access and VB, and don't even now where to start - any help will be appreciated.
    Look up the function dir(), which will return your file names.

    Further, you may need this loop

    OPEN <Filename> FOR INPUT AS #1
    WHILE not eof(1)
    LINE INPUT #1, s
    <process S>
    WEND
    CLOSE #1
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Are all of the files in the same format? What kind of format? Fixed length? Delimited? Excel? If they are all in the same format you might think about using DoCmd.TransferText or DoCmd.TransferDatabase. These commands in VBA will help you import each file. But you will need to created a File Specification first.

    Before trying to automate the process first try to import or link to the data manually using File|Get External Data|Link or Import. The wizard will walk you through it. Once you get the hang of it with all the options, then look for the Advanced button. There you will be able to set up and save a File Specification. Then you can create a Macro that will link or import a file. Once you have done that then going from a macro to DoCmd.TransferText or DoCmd.TransferDatabase should be pretty easy.

  4. #4
    Join Date
    Mar 2004
    Posts
    2
    All the files are in the same format - delimited. It is files that gets spooled out every night (reports) from a Unix system. So there is 30/31 directories with each nights files, and all the files of all the days have got the same name. The tables are already created in Access, so the data needs to be appended, and then for every day, for every file that has been imported there should be a flag set because some of the reports are empty. The big problem is that none of the files have got any info on a date. Only the directory structure specifies the date eg. //2004/02/01 next dir will be //2004/02/02 ect.

    Thanks - I appreciate

Posting Permissions

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