Getting only one of two check boxes marked


I am designing a form and I use check boxes for the user to mark ‘yes’ or ‘no’. The problem is that eventually one can check the two check boxes, which make no sense “[x] Yes [x] No”. I would like that only one of both can be checked.
For example, if the ‘Yes’ is checked and the user checks the ‘No’, the ‘Yes’ should be unchecked and vice versa.


Use Option button for that, not Check box

Thanks that was a quite first answer. Though it does not look like I wanted.

Is this for Calc, Writer or Base? Please use one of those tags instead of “common” so that we know what kind of form this is asking about. (That is why I could not give an example macro in my answer.)

@jimk: yes it is for Libreoffice Writer (I did retag the question)
If you can add the macro in your answer it would be great!

As @mikekaganski said, use option buttons.

If only one choice is allowed, then the button should look like (o) because this is the standard. Otherwise, if it looks like [x] then people will think it is possible to check both.

If you still decide to use check boxes, then write a macro to uncheck the other box.


Right-click on a check box in Design View and select Control. For the code below, set the Name properties to chkYes and chkNo. In the Events tab, use the following macro for the Execute action of both.

Sub MutuallyExclusiveCheckboxes(event As ActionEvent)
    model = event.Source.Model
    form = model.getParent()
    If model.Name = "chkYes" Then
        otherName = "chkNo"
        otherName = "chkYes"
    End If
    otherControl = form.getByName(otherName)
    otherControl.State = False
End Sub

I truly do not like the round buttons, therefore If you have some quick macro-code for the check-boxes, it would be great. Thanks

See edited answer.