I've changed clsLinkedControl and clsLinkedControls to make it more versatile and more intuitive.
clsLinkedControl.BooleanControl can now be any control, not just an OptionButton or CheckBox.
BooleanControl is deemed to be True if its value equals the .TrueValue property of the clsLinkedControl object.
Although currently written for only CheckBoxes, OptionButtons and ComboBoxes, adding a new kind of control is pretty transparent.
There are two new properties, .ClearWhenTrue and .ClearWhenFalse. Both are collections of controls whose values will be set to vbNullString when the BooleanControl is True (or False). The methods .AddClearWhenFalse and .AddClearWhenTrue have also been added.
In addition, there are methods .FollowBooleanControl and .InvertBooleanControl. Passing a user form's control as an argument for these methods will cause the control's visibility to either follow or invert the value of the BooleanControl.
I've changed the confusing syntax for the clsLinkedControls .Add method.
It now requires a msforms.Control object for the BooleanControl
The second argument, TrueValue, is optional and defaults to True.
This will make is so TextBox1 and TextBox2 are visible if, and only if, OptionButton1 is checked. TextBox3 will be visible iif OptionButton1 is unchecked.
This will make it so TextBox5 is visible iff ComboBox1.Value = "cat". Also, whenever ComboBox1.Value is changed to "cat", TextBox7 will be cleared
Here is the code for the new clsLinkedControl
and the new clsLinkedControls
Now I need to go to the OP's workbook and alter the Initialize event. And include the ComboBoxes.
Bookmarks