View Full Version : OptionButton and CheckBox together
Minderis
11-03-2011, 01:11 AM
I need to make form in Word.
Question: Do you have driver license?
Use 2 OptionButton (RadioButton) for possible answer: Yes/No
If selected Yes, I need to activate few CheckBox'es with categories of driver license (A,B,C,D).
If selected No, CheckBox'es with categories must be hidden.
How can I do this one?
p.s. please give instruction for dummy :)
gmaxey
11-03-2011, 05:29 AM
Initialize the form with the No option pre-selected and use the button click events to set the checkbox states. Change "Enabled" to "Visible" in the code below.
Private Sub UserForm_Initialize()
optNo.Value = True
End Sub
Private Sub optYes_Click()
CheckBox1.Enabled = True
CheckBox2.Enabled = True
CheckBox3.Enabled = True
CheckBox4.Enabled = True
End Sub
Private Sub optNo_Click()
CheckBox1.Enabled = False
CheckBox2.Enabled = False
CheckBox3.Enabled = False
CheckBox4.Enabled = False
End Sub
Minderis
11-03-2011, 07:05 AM
Thanks,
but it still dont work.
Step-by-step:
Open Word program->Developer->Visual Basic->Insert->UserForm->Toolbox (drag&drop 2 optionbuttons and 4 checkbox)->right-mouse-click on UserForm1->View Code, receive:
Private Sub UserForm_Click()
End Sub
Insert your code between and goto View Microsoft Word
and have nothing :(
Where I make mistakes?
gmaxey
11-03-2011, 07:17 AM
Who said anything about inserting code in the userform click event or going to Microsoft Word?
It sounds like you need to read up on how to create a userform:
http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm
Paul_Hossler
11-03-2011, 07:19 AM
"1 JPG = 1K TXT"
Open the Docm, enable macros, and run 'test' (Alt-F8)
Let me know how / if it works
Paul
Minderis
11-03-2011, 08:11 AM
It works fine.
But it works like Call Out form.
I need this form on main window of paper.
For example I attach word file ANKETA, open it and you will undersand what I need.
And I will atach Anketa_Project, this is what I done now with yours examples.
Minderis
11-03-2011, 08:15 AM
This is my project
Paul_Hossler
11-03-2011, 09:10 AM
Option Explicit
Private Sub OptionButton3_Click()
ActiveDocument.CheckBox1.Enabled = False
ActiveDocument.CheckBox2.Enabled = False
ActiveDocument.CheckBox3.Enabled = False
ActiveDocument.CheckBox4.Enabled = False
End Sub
Private Sub OptionButton4_Click()
ActiveDocument.CheckBox1.Enabled = True
ActiveDocument.CheckBox2.Enabled = True
ActiveDocument.CheckBox3.Enabled = True
ActiveDocument.CheckBox4.Enabled = True
End Sub
Paul
Minderis
11-03-2011, 10:48 AM
Thanks, this works fine :)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.