Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Post Unanswered: Pull Directory File Names into Access Table

    This is an Access Database? I have a table that has a field called ("FileName") that is currently blank with no records.

    My objective is to traverse through a directory on the hard drive and store each file name into a record in the database table. I have over 2000 file names that I want populated into those records.

    I am guessing that a trigger would work, but I have never created one and I don't know if Access has the ability to create triggers. Any Help would be appreciated?

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    In Access VBA you would use the Dir() command. To get the first filename set you filename varibale equal to the Dir(strPathName). This will give you the first file in folder. Then subsequent calls to Dir() without specifying the folder will get the next file in the folder until Dir() returns an empty string.

    Dir() will return everything in the folder, including other folders. To test whether it is a folder or not you can use:

    Public Function IsFolder(strFolder As String) As Boolean
    IsFolder = False
    If (GetAttr(strFolder) And vbDirectory) = vbDirectory Then IsFolder = True
    End Function

  3. #3
    Join Date
    Jan 2004
    Location
    Toronto, Canada
    Posts
    259
    you want to get the entire hard drive right? with the above method, it only goes through the folder you specify;....however, if you make it recursive, you can traverse the entire hard drive!

    write a function that accepts a folder name as input; the function searches through the entire folder, and if it finds subfolders, it calls itself again for that subfolder and so on...it should work.

  4. #4
    Join Date
    Feb 2004
    Posts
    3
    I am not trying to traverse the entire harddrive, just specific folders (total 6). The file names contain numbers and underscores. I believe that using Dir() (which was posted above) will solve my problem, but I haven't done any VBA scripting. I have done some VB Coding, so I should pick it up. But currently I am trying to look at some tutorials for VBA scripting, but that may take a bit. Do any of you have and good sources or ideas to get my feet wet with VBA?


    Originally posted by Jerrie
    you want to get the entire hard drive right? with the above method, it only goes through the folder you specify;....however, if you make it recursive, you can traverse the entire hard drive!

    write a function that accepts a folder name as input; the function searches through the entire folder, and if it finds subfolders, it calls itself again for that subfolder and so on...it should work.

Posting Permissions

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