control the controls with a control

  • Thread starter Thread starter TUNGANA KURMA RAJU
  • Start date Start date
T

TUNGANA KURMA RAJU

just for curiosity,can it be posiible to add control with the help of a
control,
I have 2 option buttons ,By clicking Optionbutton1=add text box1 to the
userform.
optionButton2_click=Delete/unload textbox1.
 
It's easier to just hide or unhide an existing control by toggling the
visible property of the textbox.
 
How it is incase of my question example?
What line of code has to be added to userform,if i select optionbutton 1,3
text boxes(textbox1,2,3) are to be activated and others are to be(say my
userform has 7 textboxes)disabled/hide/inactive.
 
Textbox1.Visible = false or true as the case may be. Try this as an example

Add a user form to yoru project
Add 2 option buttons and 2 text boxes to the user form.
Add the following code.

Private Sub OptionButton1_Click()
TextBox1.Visible = False
TextBox2.Visible = True
End Sub

Private Sub OptionButton2_Click()
TextBox1.Visible = True
TextBox2.Visible = False

End Sub

Run the code and toggle the option buttons on the form.
 
Back
Top