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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Option Buttons

Status
Not open for further replies.

rnathan

Programmer
Jun 27, 2002
41
0
0
US
Hi all,

I have a few option buttons in one of the forms in my application. I have set the values of all the Opt buttons to False. But when the Form gets displayed, for some reason one of the Opt button's value becomes True. I am not setting the value to True in my code and it is always the same button that gives me the problem. Even if I set the value to False to this button right after I load the Form, the next Opt button in the tab index becomes True. I have VB 6.0(SP5) and NT 4.0. Thanks in advance.

Rita
 
Did you set these option buttons up in an arry? If so, I think one of them must be selected. So it will set one of them for you.
 
An easy way top set all of the option buttons on a form to false:

For Each Control In Me
If TypeOf Control Is OptionButton Then
Control.Value = False
End If
Next

I tried this, and had an OptionButton with value set to True, and all were unchecked when the form loaded.

Good luck. I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Place a command button control on the same form as the option buttons. Leave it visible, but place it *outside* of the form's borders. Also, set it's TabStop property to True, and it's TabIndex to 1.

When the form appears, none of the radio buttons will have a dot in them. If you press tab, however, the first radio button will highlight. You can avoid this by setting the TabStop property of all of the radio buttons to False.

Robert
 
Thank you guys for all the suggestions. I've decided to use Robert's idea. Seems to be working.

Rita
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top