Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I select an option button 2

Status
Not open for further replies.

JensKKK

Technical User
May 8, 2007
119
GB
I want to load a form that contains several option button.

When I load the form all option button are de-selected.

Ideally I would like to show which data had been previously selected and therefore I would like to know how I can make my option button selected when I load the form.

Any ideas on how to make option button selected are most welcome.

Cheers
 
optionbuttonName.value = True (or = 1)

OR

If they are within a frame

OptionFrame.value = 1

where you can set values for each option button within a frame

To "remember" which options were chosen last time, you probably need to write to a hidden sheet on close and then traverse through it to pick up the values on form load



Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
something like this should get you started

Code:
Private Sub UserForm_Initialize()
Me.OptionButton1.Value = 1
End Sub

not really too sure about your further requirements. if you want to remember which options were selected and which weren't you may need to store the values either in a worksheet of as custom properties within the workbook then call them backe when initialising the form.

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
lol - a whole 3 mins too late - that's what you get for using formatting !!

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Thanks guys.

The code obviously worked pretty quickly in my workbook.

 
Here is the code

Sub initialize_settings_form()
Dim j, alpha As Integer
Dim T_Test, dRFU, percent_inhibition As Single


'Lese alte Daten ein
T_Test = Sheets("3d rotate").Cells(48, 22)
percent_inhibition = Sheets("3d rotate").Cells(50, 22)
dRFU = Sheets("3d rotate").Cells(52, 22)
alpha = Sheets("3d rotate").Cells(44, 22)

If alpha = 1 Then
Settings.OptionButton1.Value = 1
Else
Settings.OptionButton2.Value = 1
End If


'***************************
'Populate T-Test combobox
'***************************
Settings.ComboBox1.Clear
For j = 1 To 100
Settings.ComboBox1.AddItem j / 100
Next
Settings.ComboBox1.ListIndex = Int(T_Test * 100) - 1
'***************************
'Populate % Inhibition combobox
'***************************
Settings.Controls("ComboBox" & 2).Clear
For j = 0 To 100
Settings.Controls("ComboBox" & 2).AddItem j
Next
Settings.ComboBox2.ListIndex = Int(percent_inhibition)

'***************************
'Populate % Inhibition combobox
'***************************
Settings.Controls("ComboBox" & 3).Clear
For j = 0 To 200
Settings.Controls("ComboBox" & 3).AddItem j * 10
Next
If dRFU > 0 Then
Settings.ComboBox3.ListIndex = Int(dRFU / 10)
Else
Settings.ComboBox1.ListIndex = 0
End If
Settings.Show
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top