0

I have an open MS Access database with 20 tables showing in the left and two tabs open showing the contents of two tables. I am trying to write vba code to 1) select/activate one of the tabs that is already open, and 2) to open a new tab for one of the tables on the left that is not yet open.

I've looked at many examples, but they all talk about Forms, not the tab control/tabs that I want to work with in the main Access table display. Here's my code so far - I can get the name of the table, but I can't figure out how to open and activate a tab for the table in the Access display.

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
0

1 Answer 1

2

Just use DoCmd.OpenTable.

DoCmd.OpenTable tbl.Name

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.