【发布时间】:2020-05-29 15:56:34
【问题描述】:
我有一个开放的 MS Access 数据库,左侧显示了 20 个表,并且打开了两个选项卡,显示了两个表的内容。我正在尝试编写 vba 代码以 1)选择/激活已打开的选项卡之一,以及 2)为左侧尚未打开的表之一打开一个新选项卡。
我查看了许多示例,但它们都在谈论表单,而不是我想在主 Access 表显示中使用的选项卡控件/选项卡。到目前为止,这是我的代码 - 我可以获得表的名称,但我不知道如何在 Access 显示中打开和激活表的选项卡。
Sub ActivateCommandsTable()
' activate or open a tab for the Commands table
Dim tbl As AccessObject, db As Object
Set db = Application.CurrentData
' Search for open AccessObject objects in AllTables collection.
For Each tbl In db.AllTables
If tbl.IsLoaded = True Then
' Print name of the table
Debug.Print tbl.name
If tbl.name = "Commands" Then
' I need some code here to activate/open the table tab
Exit Sub
End If
End If
Next tbl
End Sub
【问题讨论】: