【问题标题】:Show value based on selection in combo box vba根据组合框vba中的选择显示值
【发布时间】:2015-05-12 16:13:19
【问题描述】:

我需要在我的访问表单中根据组合框中的选择显示面额

这里棘手的是我需要在组合框中选择后立即显示(不保存)。在我保存我的选择之后,这个就可以工作了。

If cmb_Main_Impact.Value = "Productivity" Then
Me.txt_Units = "minutes"
End If

If cmb_Main_Impact = "Quality" Then
Me.txt_Units = "number of errors"
End If

【问题讨论】:

  • 你把代码放在哪里了?你的 ComboBox 在用户窗体中吗?
  • 该代码应该在组合框的 AfterUpdate 事件中运行。组合框没有保存事件。

标签: vba ms-access text combobox


【解决方案1】:

该代码应该可以正常工作。你想把它放在更改事件的组合框中。

还添加了一个 elseif,因此没有多个 if 和 end if。将该代码放入具有组合框的用户表单中。

所以你的代码看起来像。

Private Sub cmb_Main_Impact_Change()

    If cmb_Main_Impact.Value = "Productivity" Then
        Me.txt_Units = "minutes"

    elseIf cmb_Main_Impact = "Quality" Then
        Me.txt_Units = "number of errors"
    End If

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-03
    • 2019-09-18
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多