noelmcg
noelmcg

Reputation: 1067

How do you find out if a control is located on a tab control?

Hopefully this should be fairly easy, although after much searching I cant figure this out.

How do you find out if a control is located on a tab?

If ctl.ControlType <> 'Tab Controls' Then
.....
End if

The reason for doing this is that I have a piece of code that runs through the controls on a form, but runs into a problem when cycling through controls on a tab.

 If ctl.Parent.CurrentView <> 2 Then
            MsgBox ctl.Name
 End If

The above causes the error:

Error: 348 Object doesnt support this property or method

Obviously it appears you cant refer to the current view of a tab control

Cheers for any advice any one has got out there

Noel

Upvotes: 0

Views: 341

Answers (1)

smirkingman
smirkingman

Reputation: 6368

Check what ctl is before using CurrentView:

Select Case ctl.ControlType
    Case acCheckBox
        ' do something for check box
    Case acTabCtl
        ' do something for tab control
End Select

Upvotes: 2

Related Questions