如何清除大多数表单(而非全部)的访问控制?我有一个要重置而不是清除的控件(Combo55),但不确定如何更改命令来执行此操作。现在的代码如下:
Private Sub Command2061_Click()
'Clear
Const cstrPrompt As String = _
"Are you sure you want to Clear this Form? Yes/No"
If MsgBox(cstrPrompt, vbQuestion + vbYesNo) = vbYes Then
Dim Ctl As Control
On Error Resume Next
For Each Ctl In Me.Controls
Ctl.Value = Null
Next Ctl
End If
End Sub
您可以测试每个控件的名称,然后执行所需的操作
Private Sub Command2061_Click()
'Clear
Const cstrPrompt As String = _
"Are you sure you want to Clear this Form? Yes/No"
If MsgBox(cstrPrompt, vbQuestion + vbYesNo) = vbYes Then
Dim Ctl As Control
On Error Resume Next
For Each Ctl In Me.Controls
If Ctl.Name = "Combo55" Then
'Your action here
'Ctl.Value = "reset value"
Else
Ctl.Value = Null
End if
Next Ctl
End If
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句