根据主复选框的选择切换选项卡中的复选框 [英] Toggle checkboxes in a tab based upon master checkbox selection
问题描述
我在vba表单中的复选框的onclick事件上遇到问题.基本上,我想做的是将特定选项卡上所有复选框的值都修改为与主复选框相同的值.在这种情况下,下面的使用在线"字幕复选框(代码中的online_toggle)一旦单击,应将选项卡上的其他复选框切换为打开"或关闭".我目前有以下代码,但在对于online.OLEObjects中的每个obj"中,它会不断产生错误
I'm having issues with an onclick event for a checkbox in a vba form. Basically what I am trying to do is ammend the value of all checkboxes on specific tab to be the same value as a master checkbox. In this instance, it is the 'Use Online' captioned checkbox below (online_toggle in the code) which once clicked should toggle the other checkboxes on the tab 'on' or 'off'. I currently have the following code but it keeps producing an error at 'For Each obj In online.OLEObjects'
Private Sub online_toggle_Click()
Dim ctl As Control
For Each ctl In Me.MultiPage1.Pages(6).Controls
If TypeOf ctl Is MSForms.CheckBox Then
If ctl.GroupName = "online_variants" Then
If ctl.Name <> "online_toggle" Then
ctl.Value = online_toggle.Value
End If
End If
End If
Next ctl
End Sub
online是所有复选框所在的选项卡的名称.如果有帮助,则受主复选框影响的复选框全部分组为online_variants
N.B. online is the name of the tab on which all of the checkboxes are situated. If it helps the checkboxes affected by the master checkbox are all grouped as online_variants
干杯
Jason
推荐答案
在Mutipage中,页码从0开始,因此,如果您要引用 Online
选项卡(第7个选项卡)中的复选框,),然后使用此
In a Mutipage the page numbering starts from 0 so if you are trying to refer to the Checkboxes in the Online
tab (7th Tab) then use this
Dim ctl As Control
For Each ctl In Me.MultiPage1.Pages(6).Controls
If TypeOf ctl Is MSForms.CheckBox Then
'~~> Your code here
Debug.Print ctl.Name
End If
Next
这篇关于根据主复选框的选择切换选项卡中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!