CheckBox

D

DebbieF

Is there a way to program checkboxes so
that if one box is checked, the other cannot be checked?
In other words, if you check one and then another, it
clears the previous one you checked.
 
H

Harald Staff

Hi

Yes. But Optionbuttons (aka Radio buttons) do this. Checkboxes are used
where this behavior is not desired.

HTH. Best wishes Harald
 
H

Harald Staff

Ok, I told you yesterday and still you insist:

Option Explicit
Dim blnAuto As Boolean

Private Sub CheckBox1_Click()
If blnAuto Then Exit Sub
If CheckBox1.Value = True Then
blnAuto = True
CheckBox2.Value = False
CheckBox3.Value = False
blnAuto = False
End If
End Sub

Private Sub CheckBox2_Click()
If blnAuto Then Exit Sub
If CheckBox3.Value = True Then
blnAuto = True
CheckBox1.Value = False
CheckBox3.Value = False
blnAuto = False
End If
End Sub

Private Sub CheckBox3_Click()
If blnAuto Then Exit Sub
If CheckBox3.Value = True Then
blnAuto = True
CheckBox1.Value = False
CheckBox2.Value = False
blnAuto = False
End If
End Sub

Users do not expect this behavior from checkboxes.

Best wishes Harald
 
D

DebbieF

Thank you very much. This works like a charm.
-----Original Message-----
Ok, I told you yesterday and still you insist:

Option Explicit
Dim blnAuto As Boolean

Private Sub CheckBox1_Click()
If blnAuto Then Exit Sub
If CheckBox1.Value = True Then
blnAuto = True
CheckBox2.Value = False
CheckBox3.Value = False
blnAuto = False
End If
End Sub

Private Sub CheckBox2_Click()
If blnAuto Then Exit Sub
If CheckBox3.Value = True Then
blnAuto = True
CheckBox1.Value = False
CheckBox3.Value = False
blnAuto = False
End If
End Sub

Private Sub CheckBox3_Click()
If blnAuto Then Exit Sub
If CheckBox3.Value = True Then
blnAuto = True
CheckBox1.Value = False
CheckBox2.Value = False
blnAuto = False
End If
End Sub

Users do not expect this behavior from checkboxes.

Best wishes Harald

"DebbieF" <[email protected]> skrev i melding


.
 
H

Harald Staff

DebbieF said:
Thank you very much. This works like a charm.

Guess you have your valid reasons for this design, apologies for questioning
them. Thanks for the feedback.

Best wishes Harald
 
F

Frank Kabel

Hi Harald
probably like you I'm a little bit curious what design decisions these
are ;-))
 
Top