-
Hi,
What I'm trying to do is to write some code which will treat an array
of CheckBoxes just like they were option boxes so that only 1 CheckBox
can be selected at a time. But the catch is that the user should also
be able to not have any selections which is why I'm using the CheckBox.
For example, I have a control array of 4 CheckBoxes named chkShipPay.
If index 3 is currently selected and the user clicks on index 2, 3 should be unchecked
and 2 should be checked. If the user then clicks 2 again, it should be unchecked.
I tried various code in the click event but it allways seems to go in an infinite
loop and terminates..
Any help or ideas would be greatly appreciated..
Dan
-
Try this:
Not Tested!!!
Code:
Private Sub chkShipPay_Click (Index As Integer)
Dim chk as CheckBox
For Each chk In chkShipPay
chk.Value = 0
Next
chkShipPay(Index).Value = 1
End Sub
-
Thanks, but doesn't work either.. It also goes into an infinite loop. Also, even if your code were to work, it wouldn't allow for "deselecting" a checkbox.. There would allways be 1 checked.. But remember, I want to also allow the user the option of not making any selections or deselecting an already selected option..
-
Why not have options buttons. If you want the choice of having no items selected, make a "None" option.
-
Sorry, I wasn't thinking, go with Megatron
-
Okay, Megatron's suggestion will work.. I thought about that but just wanted to see if I could make it work but I guess it won't be simple..