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!

Option Button / Check Box 1

Status
Not open for further replies.

gayley

Technical User
Sep 24, 2003
4
GB
I'm stuck on part of a form I'm trying to create. I want to have a row of check boxes or option buttons that can all be selected at the same time (like check boxes) but which look like option buttons. Is this possible? I can't work out how to change the look of a check box, or alternatively how to get a range of option buttons to allow more than one to be selected.
 
It is possible with some cheating.
To separate optionbuttons, place each on small separates frames with no caption and specialeffect flat. The problem arises to "uncheck" such optionbutton. Again, cheat. Place label on the top of each, with no caption and backstyle transparent. Add code to label (here Label1 covers OptionButton1):
[tt]Private Sub Label1_Click()
Me.OptionButton1.Value = Not Me.OptionButton1.Value
End Sub[/tt]

combo
 
Not sure why you would want to do this. Is the intent to confuse or anger the user?

If you insist on doing this, then the way is to give each OptionButton a unique value in its GroupName property.

The problem is, once clicked, there is no way to un-click it again (like a check box would). So you would either have to have OptionButtons set up in pairs or have a CommandButton that can turn them all off at once with something like this:
[blue]
Code:
Private Sub CommandButton1_Click()
Dim oControl As Control
  For Each oControl In Controls
    If Left(oControl.Name, 12) = "OptionButton" Then
      oControl.Value = False
    End If
  Next oControl
End Sub
[/color]

I would really like to know why you want to use option buttons in that way.
 
It's really just a visual reason why I want to do this. It's a record of elements out of a list that are missing - basically the look of an option button is more sensible than a tick. That's why I was equally interested in changing the look of a tick box. I realise that that's really what I should be using for what I want.
 

combo: Very nice. I wish I had thought of using a label that way.
 
Zathras: The GroupName property - easy and clever - obvious, but never used it before (
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top