Ask Your Question

Getting only one of two check boxes marked

asked 2017-11-14 13:41:50 +0100 gravatar image

updated 2017-11-20 12:45:36 +0100


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.


edit retag flag offensive close merge delete



Use Option button for that, not Check box

Mike Kaganski gravatar imageMike Kaganski ( 2017-11-14 14:03:14 +0100 )edit

Thanks that was a quite first answer. Though it does not look like I wanted. gravatar ( 2017-11-14 14:49:13 +0100 )edit

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.)

Jim K gravatar imageJim K ( 2017-11-14 17:15:09 +0100 )edit

@Jim K: yes it is for Libreoffice Writer (I did retag the question) If you can add the macro in your answer it would be great! gravatar ( 2017-11-20 12:43:50 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-11-14 17:09:19 +0100

Jim K gravatar image

updated 2017-11-20 19:44:33 +0100

As @Mike Kaganski 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
edit flag offensive delete link more


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 gravatar ( 2017-11-20 12:46:48 +0100 )edit

See edited answer.

Jim K gravatar imageJim K ( 2017-11-20 19:44:43 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-11-14 13:41:50 +0100

Seen: 49 times

Last updated: Nov 20 '17