Share via

Adding Tabs to a form

Patrick Snyder 5 Reputation points
2026-02-12T20:02:25.0033333+00:00

I got help from Dora-T getting two combo boxes to filter a subform. Below is the VBA to make it work.

Option Compare Database
Private Sub Combo5_AfterUpdate()
    Me.Combo10 = Null
    Me.Combo10.Requery
    RefreshSubform
End Sub
Private Sub Combo10_AfterUpdate()
    RefreshSubform
End Sub
Private Sub btnClear_Click()
    Me.Combo5 = Null
    Me.Combo10 = Null
    Me.Combo10.Requery
    RefreshSubform
End Sub
Private Sub RefreshSubform()
    Dim strSQL As String
    Dim strWhere As String
    strSQL = "SELECT * FROM Data"
    strWhere = ""
    If Not IsNull(Me.Combo5) Then
        strWhere = "[Cty] = '" & Me.Combo5 & "'"
    End If
    If Not IsNull(Me.Combo10) Then
        If strWhere <> "" Then strWhere = strWhere & " AND "
        'strWhere = strWhere & "[RFQ_num] = '" & Me.Combo10 & "'"
        strWhere = strWhere & "[Cust_ind_std] = '" & Me.Combo10 & "'"
    End If
    If strWhere <> "" Then
        strSQL = strSQL & " WHERE " & strWhere
    End If
    With Me.Country.Form
        .RecordSource = strSQL
        .Requery
    End With
End Sub

The combo boxs are located in the header of the form. What I want to do now is add a series of tabs within the form. Each tab will have the same layout, two combos and a subform but each tab will be sorting or filter for a different characteristic.

So, I've created tabs in the form, I've cut/pasted the subform into the 1st tab and the combo boxes are still in the header and everything still works. When I cut/paste the combo boxes from the header into the tab with the subform, this is when the combox boxes stop working.

How do I fix this?

Microsoft 365 and Office | Access | Other | Windows

2 answers

Sort by: Most helpful
  1. Anonymous
    2026-02-12T23:31:50.2933333+00:00

    Hi Patrick Snyder

    Thank you for reaching out to the Microsoft Q&A Forum and for sharing your experience.
    Before recommending any additional changes, I’d like to take a bit more time to continue testing and validating this behavior, particularly the difference you’re seeing when the combo boxes are moved from the form header into a tab page. This helps ensure that any guidance provided is accurate and avoids unnecessary troubleshooting or confusion.

    If possible, could you share a simplified sample database that reproduces the issue with the tab control, combo boxes, and subform? Having a working example will help me better understand how the controls are laid out and continue testing the behavior more precisely.

    Because this is a public forum, I recommend not posting files or screenshots that contain personal or organizational information. To help protect your data, please send any supporting documents or screenshots via Private Message instead.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


  2. AI answer

    2026-02-12T20:02:37.9333333+00:00

    When you move the combo boxes from the header of the form to a tab control, you need to ensure that the references to the combo boxes in your VBA code are updated accordingly. Here are some steps to help you fix the issue:

    1. Update References in VBA: When the combo boxes are moved to a tab, they are no longer directly accessible from the form. You need to reference them through the tab control. For example, if your tab control is named TabControl1 and the combo boxes are named Combo5 and Combo10, you would reference them like this:
         Me.TabControl1.Controls!Combo5
         Me.TabControl1.Controls!Combo10
      
      Update all instances in your VBA code where you reference Combo5 and Combo10 to include the tab control.
    2. Ensure Tab Control is Active: Make sure that the correct tab is active when you are trying to access the combo boxes. If the tab is not active, the controls may not behave as expected.
    3. Requery the Combo Boxes: After moving the combo boxes, ensure that they are requeried properly. You can do this in the AfterUpdate event of the combo boxes to refresh the data based on the selected values.
    4. Test Functionality: After making these changes, test the functionality of the combo boxes to ensure they are filtering the subform as intended.

    By following these steps, you should be able to get the combo boxes working correctly within the tab control of your form.

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.