Results 1 to 4 of 4
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    Get Table Data

    I am wanting to open the database stored in the variable filename. It prints the proper full location, and has 1 table in it called TestTable, however when I execute the code below it only prints the table names of the database I am executing the code from (which has no tables). How can I change the focus to the secondary database?


    Code:
     Function GetTableInfo(ByVal filename As String)
     Dim accapp As Access.Application
     Set accapp = New Access.Application
     Debug.Print (filename)
     accapp.OpenCurrentDatabase (filename)
     accapp.Visible = True
        Dim db As DAO.Database
        Dim tdf As DAO.TableDef
        Set db = CurrentDb
        For Each tdf In db.TableDefs
        Debug.Print (tdf.name)
            If Not (tdf.name Like "MSys*") Then
                WriteData tdf.name, tdf.connect
            End If
        Next
        Set tdf = Nothing
        Set db = Nothing
     End Function

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    if the internal db tables have no links, then there will be no connect path.
    If you want the paths to a different db, run this code in THAT database.

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Quote Originally Posted by ranman256 View Post
    if the internal db tables have no links, then there will be no connect path.
    If you want the paths to a different db, run this code in THAT database.
    that is where my issue lies. I am recursively scanningn for .accdb files in a folder, and I want to open each .accdb found and list the linked tables.

    So I am needing a parent --> child relationship or master --> sub.

    Master would be the db I am executing code from and sub would be the database that was opened to get table info.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    For Each tdf In db.TableDefs
    You are looping thru the TableDefs of db which is set to CurrentDB. Change the line to "Set db = accapp.CurrentDb"

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 08-11-2016, 11:30 AM
  2. Replies: 5
    Last Post: 08-25-2015, 08:39 AM
  3. Replies: 1
    Last Post: 05-31-2015, 09:20 AM
  4. Replies: 5
    Last Post: 09-06-2013, 11:52 AM
  5. Replies: 13
    Last Post: 10-04-2012, 04:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums