在MS-Access中访问隐藏表的VBA语法是什么?

时间:2022-10-04 12:13:52

I want to create a list of all tables in an ms Access database including those that are hidden.

我想创建ms Access数据库中所有表的列表,包括隐藏的表。

2 个解决方案

#1


The following will print the name of each table to the immediate window.

以下内容将每个表的名称打印到即时窗口。

Sub ShowAllTables()

    Dim obj As AccessObject

    For Each obj In Application.CurrentData.AllTables
            Debug.Print obj.Name
    Next obj

End Sub

#2


I don't know whether an AccessObject can tell you whether the table is hidden but ADO certainly can e.g.

我不知道AccessObject是否可以告诉您表是否被隐藏但ADO当然可以例如

Sub ShowAllTables2()

  Dim cat
  Set cat = CreateObject("ADOX.Catalog")

  With cat
    .ActiveConnection = CurrentProject.Connection

    Dim t
    For Each t In .tables
      Debug.Print t.Name, t.Properties("Jet OLEDB:Table Hidden In Access").Value
    Next

  End With

End Sub

#1


The following will print the name of each table to the immediate window.

以下内容将每个表的名称打印到即时窗口。

Sub ShowAllTables()

    Dim obj As AccessObject

    For Each obj In Application.CurrentData.AllTables
            Debug.Print obj.Name
    Next obj

End Sub

#2


I don't know whether an AccessObject can tell you whether the table is hidden but ADO certainly can e.g.

我不知道AccessObject是否可以告诉您表是否被隐藏但ADO当然可以例如

Sub ShowAllTables2()

  Dim cat
  Set cat = CreateObject("ADOX.Catalog")

  With cat
    .ActiveConnection = CurrentProject.Connection

    Dim t
    For Each t In .tables
      Debug.Print t.Name, t.Properties("Jet OLEDB:Table Hidden In Access").Value
    Next

  End With

End Sub