问题描述
好了,所以我有几个复选框的访问形式。所有我想要做的是让经过的复选框中的价值。
Okay so I have couple of "checkboxes" in Access form. All I am trying to do is to get Checked Value of the checkbox.
这样做Me.Check271.Value它返回我0或-1。但
By doing Me.Check271.Value it returns me 0 or -1. But
我希望得到尊重选中的复选框中的标签
I want to get respected label of the checked CheckBox.
在图片下面我想MSGBOX这些检查值:
In picture below I want to msgbox the values which are checked:
我想做的是:
MSGBOXMe.Check271.Parent
MsgBox "Me.Check271.Parent"
非常感谢
推荐答案
简单地说,下面的工作:
Briefly, the following will work:
Check271.Controls.Item(0).Caption
详细的版本:文本框,组合框,列表框,复选框有一个最大的1项在其控件集合(附标签),但如果标签没有连接,他们甚至不会有,所以.Controls( 0),将抛出一个错误。
Verbose Version: TextBoxes, ComboBoxes, ListBoxes, CheckBoxes have a maximum of 1 item in their controls collection (the attached label), but if the label isn't attached, they won't even have that, so .Controls(0) will throw an error.
下面将显示复选框被检查
The following will show Checkboxes that are 'checked'
Dim ctl As Control
Dim blnChecked As Boolean
Dim strChecked As String
For Each ctl In Me.Section("Detail").Controls
If ctl.ControlType = acCheckBox Then
If ctl.Enabled = True Then
Debug.Print ctl.Name & vbTab & ctl.Value
If ctl.Value = vbTrue Then
blnChecked = True
strChecked = strChecked & ctl.Name & "; "
End If
End If
End If
Next ctl
If blnChecked = True Then
MsgBox "The following CheckBoxes were checked: " & strChecked, vbOKOnly, "Checked Boxes"
End If
这篇关于获取选中的复选框的值在VBA访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!