【问题标题】:Access 2013 vba - clear a form's controls, bypassing calculated controlsAccess 2013 vba - 清除表单的控件,绕过计算的控件
【发布时间】:2015-05-30 10:13:42
【问题描述】:

我想清除 Access 2013 表单中的所有控件。我在这个网站上找到了 Johan Godfried 的以下脚本,它运行良好。

Private Sub resetForm()

Dim ctl As Control

For Each ctl In Me.Controls
    Select Case TypeName(ctl)
        Case "TextBox"
            ctl.value = ""
        Case "CheckBox", "ToggleButton"
            ctl.value = False
        Case "OptionGroup"
            ctl = Null
        Case "OptionButton"
            ' Do not reset an optionbutton if it is part of an OptionGroup
            If TypeName(ctl.Parent) <> "OptionGroup" Then ctl.value = False
        Case "ComboBox", "ListBox"
            ctl.RowSource = vbNullString
    End Select
    Next ctl
 End Sub

除了当迭代选择计算控件时,我收到以下错误: 您不能为此对象赋值

是否有可用于绕过计算控件的属性?

【问题讨论】:

  • 对于您希望清除的控件,您拥有什么作为控件源属性?这些目标控件的控件源是否为空?

标签: ms-access vba ms-access-2013


【解决方案1】:

尝试Me.myControl.controlsource="" 解除该控件的绑定

然后拨打resetForm()

【讨论】:

    猜你喜欢
    • 2014-12-13
    • 1970-01-01
    • 2018-03-24
    • 2016-10-30
    • 1970-01-01
    • 2016-07-28
    • 2013-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多