Ms Access隐藏和显示字段基于组合框的选择 [英] Ms Access Hide and Show Fields based on combo box choice

查看:91
本文介绍了Ms Access隐藏和显示字段基于组合框的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Access中有一个用户表单.在我的用户窗体中,我有一个带有3个选项的ComboBox:A,B和C.基于这些值,我想隐藏/取消隐藏文本框.这是场景:

I have a Userform in Access. In my Userform I have a ComboBox with 3 option: A, B and C. Based on there values, I would like to hide/unhide Text boxes. This is the scenario:

当我选择A时,我想自动执行以下操作. *显示文字框1 *隐藏文本框2

When i select A i want to automatically do the following. * Show text box 1 * Hide text box 2

当B *隐藏文本框1 *显示文本框2

When B * Hide textbox 1 * Show textbox 2

当C *显示文本框1 *显示文本框2

When C * Show textbox 1 * Show textbox 2

这怎么办?

推荐答案

您想要的是利用ComboBox的After Update事件,该事件将说明何时需要执行的操作的逻辑.像

What you want is to make use of the After Update event of the ComboBox, which will say the logic of what needs to be done when. Something like,

Private Sub comboBoxName_AfterUpdate()
    Select Case Me.comboBoxName
        Case "A"
            Me.textBox1Name.Visible = True
            Me.textBox2Name.Visible = False
        Case "B"
            Me.textBox1Name.Visible = False
            Me.textBox2Name.Visible = True
        Case Else
        'Case "C" is also valid
            Me.textBox1Name.Visible = True
            Me.textBox2Name.Visible = True
    End Select
End Sub

这篇关于Ms Access隐藏和显示字段基于组合框的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆