Get the name of local table and linked table in vba

♀尐吖头ヾ 提交于 2019-12-24 13:52:36

问题


I have five tables in my application in which two are local table and three are linked table, I'm not sure about my code how to get name of table. I want a code for provide me name of both type of table name separately using for loop.

Table Name

LocalTable1
LocalTable2
LinkTable1
LinkTable2
LinkTable3

Code

Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
  Debug.Print td.Name 
Next

回答1:


You can use the source table name:

Dim db As Database
Dim tdf As TableDef

Set db = CurrentDb

For Each tdf In db.TableDefs
    If Left(tdf.Name, 4) <> "MSys" Then
        Debug.Print tdf.Name & IIf(tdf.SourceTableName <> "", "  source table: " _
            & tdf.SourceTableName, "")
    End If
Next


来源:https://stackoverflow.com/questions/25579591/get-the-name-of-local-table-and-linked-table-in-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!