Results 1 to 4 of 4

Thread: Folder Contents

  1. #1
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100

    Unanswered: Folder Contents

    This might be impossible!!

    I have 120 databases in a folder which I want to import all the tables in each db to a master db. The tables are identical in all db's (I have so many dbs as I have been downloading XML data).

    Is it possible to loop through the db's in the folder and append the tables in each db to the master db??

    Any help much appreciated!!!!

  2. #2
    Join Date
    May 2002
    Location
    London
    Posts
    87
    As a start I'll give you the approach I use for working through folders. There are probably varios ways to approach this but I've always used the FileSystemObject. You need to reference "Microsoft Scripting Runtime" first and I have a quick demo below to get you started:

    Code:
    Sub FSO_demo()
    Dim fso As Scripting.FileSystemObject
    Dim fdr As Scripting.Folder
    Dim fle As Scripting.File
    
    Set fso = New FileSystemObject
    Set fdr = fso.GetFolder("C:\")
    
    For Each fle In fdr.Files
        Debug.Print fle.Name
    Next
    
    End Sub

    Now presumably your next stage is to open each database from code and iterate through the tabledefs collection to haul them in.

  3. #3
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100
    thanks for that, I'll have a local table in the master db that will have the names of all the tables so it will loop through that and append each table in turn.

    Thanks again

  4. #4
    Join Date
    May 2002
    Location
    London
    Posts
    87
    FSO seems quite neat to me. You can easily create a recusive procedure to list the items in sub-folders.

    http://msdn.microsoft.com/library/de...ereference.asp for reference.
    Last edited by Risky; 08-07-03 at 13:48.

Posting Permissions

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