PDA

View Full Version : How to hide textbox in userform by option button?



alex009988
07-17-2019, 06:22 AM
How to hide textbox in userform by option button?
I've tried to use that code


Private Sub OptionButton1_Click()
TextBox7.Visible = True
End Sub
.....
Private Sub TextBox7_Change()
TextBox7.Visible = False
End Sub


But it dosen't work. Morover, I can tick the option button but I cannot untick it.

Paul_Hossler
07-17-2019, 06:49 AM
1. Try a CheckBox instead of an OptionButton, or 2. add 2 OptionButtons in a Frame

PS -- I don't think you want the TextBox_Change

alex009988
07-17-2019, 06:59 AM
Thank you for your reply.


Private Sub CheckBox1_Click()
TextBox7.Visible = True
End Sub
Private Sub TextBox7_Change()
TextBox7.Visible = False
End Sub


How to hide TextBox7 by defaults, seems the code on Private Sub TextBox7_Change() dosent's works, as by defaults it's unhidden.

Paul_Hossler
07-17-2019, 09:45 AM
Still don't think you want TextBox1_Change



Private Sub CheckBox1_Click()
TextBox7.Visible = CheckBox1.Value
End Sub