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

Grouping checkboxes so only one can be checked

Status
Not open for further replies.

djburnheim

Technical User
Jan 22, 2003
71
0
0
AU
I'm sure this is very easy but I just can't find a way to do it....I have 4 checkboxes in a frame on a form, 2 lots of YES/NO. I want the user to be only able to check one, ie yes or no. I've tried using if then for the click event but this doesn't seem to work properly and actually crashes my machine. The best I have is below but if on is checked you seem to have to click on the other twice, eg if Yes is checked, clicking on No once unchecks Yes but you then have to click again to check No???

Private Sub chkYes1_Click()
chkNo1.Value = False
End Sub

Private Sub chkNo1_Click()
chkYes1.Value = False
End Sub

Any suggestions?
 
Why not using OptionGroup ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try using optionbuttons instead of checkboxes. Each pair of buttons, i.e. Yes and No, will have to be within its own frame. Only one of the 2 buttons can only be selected.

Hope this helps
Adam
 
You could use this trick :

in the AfterUpdate of all checkboxes, write some code to change the other checkbox. For example : the code for the first pair of checkboxes:

Private Sub chkYes1_AfterUpdate()
chkNo1.Value = Not(chkYes1.Value)
End Sub

Private Sub chkNo1_AfterUpdate()
chkYes1.Value = Not(chkNo1.Value)
End Sub


Like this, no matter what the user clicks, it will always "unclick" the opposite.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top