Code should be posted as text between CODE tags, not as image.
Why use Enabled property? If you want to make tab control visible, use Visible property. However, not seeing the Enabled line in code image.
Combobox is on a subform and tab control is on main form? Why is CaseID all by itself in upper subform? Is CaseID from same table for both forms?
I have had to do this. Example from my project - note that the tab control is not referenced, just its pages; also focus is set away from tab control because any page that has focus cannot be hidden:
Code:
Private Sub ShowTabs()
With Me
.tbxSet = TestSet(.tbxLABNUM, "Soils & Aggregate")
.pge1.Visible = True
.pge2.Visible = True
.pge3.Visible = True
.pge4.Visible = True
.pge5.Visible = True
.pge6.Visible = True
.tbxLABNUM.SetFocus
'use Val to capture characters preceeding :### which will be present if gradation test selected
If Not Val(.tbxSet) Like "*1*" Then
.pge1.Visible = False
End If
If Not Val(.tbxSet) Like "*2*" Then
.pge2.Visible = False
End If
If Not Val(.tbxSet) Like "*3*" And Not Val(.tbxSet) Like "*E*" Then
.pge3.Visible = False
End If
If Not .tbxSet Like "*P*" Then
.pge4.Visible = False
End If
If Not .tbxSet Like "*V*" Then
.pge5.Visible = False
Else
.pge2.Visible = False
End If
If Not .tbxSet Like "*H*" Then
.pge6.Visible = False
End If
If .pge6.Visible Then
.pge6.SetFocus
ElseIf .pge1.Visible Then
.pge1.SetFocus
ElseIf .pge2.Visible Then
.pge2.SetFocus
ElseIf .pge3.Visible Then
.pge3.SetFocus
ElseIf .pge4.Visible Then
.pge4.SetFocus
ElseIf .pge5.Visible Then
.pge5.SetFocus
End If
End With
End Sub
At least one page must always be visible so procedure starts with setting them all visible then hiding what is not needed.
For hiding, you could use:
Me.Parent.Page0.Visible = Me.CaseCombo = 1
Me.Parent.Page1.Visible = Me.CaseCombo = 2
Me.Parent.Page2.Visible = Me.CaseCombo = 3
Then to set focus:
Me.Parent("Page" & Me.CaseCombo - 1).SetFocus
But why bother with this? User could just as easily click on appropriate tab as select from combobox.