如何确定控件是否位于选项卡控件上?

时间:2010-12-03 12:17:59

标签: ms-access-2007 access-vba

希望这应该是相当容易的,虽然经过多次搜索我无法弄清楚这一点。

如何确定控件是否位于选项卡上?

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

这样做的原因是我有一段代码贯穿表单上的控件,但在选项卡上的控件循环时会遇到问题。

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

以上导致错误:

Error: 348 Object doesnt support this property or method

显然,你似乎无法引用标签控件的当前视图

欢呼任何人有任何建议

诺尔

1 个答案:

答案 0 :(得分:2)

在使用ctl之前检查CurrentView的内容:

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