Toggle visibility of other fields on form based upon combobox selection - MS Access

怎甘沉沦 提交于 2021-01-29 05:33:52

问题


Question...

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???

example


回答1:


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.



来源:https://stackoverflow.com/questions/65114592/toggle-visibility-of-other-fields-on-form-based-upon-combobox-selection-ms-acc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!