根据组合框选择切换表单上其他字段的可见性-MS Access [英] Toggle visibility of other fields on form based upon combobox selection - MS Access

查看:62
本文介绍了根据组合框选择切换表单上其他字段的可见性-MS Access的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题...

如何根据组合框项目的选择在表单上切换其他几个字段(复选框/文本框)的可见性.下图显示了一个列表框,但是无论如何,如何使用vba代码打开或关闭灰色框中所有字段的可见性.基本上,如果组合框选择是预定的,则visible = true.否则visible = false,我该如何编码???

How can I toggle the visibility of several other fields (checkboxes/textboxes) on form based upon the selection of a combobox item. The image below shows a listbox but either way, how do use vba code to turn on or off visibility of all the fields in the grey box. Basically, if the combobox selection is scheduled then visible=true. Else visible=false How can I code this???

推荐答案

使用组合框AfterUpdate事件,也可能会形成Current事件.因此,建立一个可以从两个事件中调用的过程,例如:

Use combobox AfterUpdate event and probably form Current event as well. So build a procedure that can be called from both events, something like:

Sub Form_Current()
SetVisible
End Sub

Sub cbo1_AfterUpdate()
SetVisible
End Sub

Sub SetVisible()
Me.tbx1.Visible = Me.cbo1 = "scheduled"
Me.cbx1.Visible = Me.cbo1 = "scheduled"
End Sub

替代方法是对文本框和组合框使用条件格式设置(对不起,不适用于其他控件)以启用/禁用以及设置颜色,使其看起来不可见.

Alternative is to use Conditional Formatting for textboxes and comboboxes (sorry, not applicable to other controls) to Enable/Disable as well as set colors so appear not visible.

这篇关于根据组合框选择切换表单上其他字段的可见性-MS Access的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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