Force a checkbox to be checked, but allow only one checkbox to be checked

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mtdean60
    New Member
    • Jun 2013
    • 1

    Force a checkbox to be checked, but allow only one checkbox to be checked

    I have an Access 2010 form with 4 checkboxes, along with other fields. On the OnClick event each checkbox sets the value of a field with some text that I use later in a report. However, sometimes users will not check a box or will check 2 boxes, which causes the report text to be incorrect. I want a messagebox to tell them they must check a box if they did not and keep the form open on the same record if they try to close the form or move to another record. However, I also want to clear all check boxes and have a messagebox if they check more than one box. I am not sure which event I need to put the code/macro on or whether to use else or elseif for some of the flow. Or am I on the wrong track completely. Thanks for any assitance.
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    I would use an option group and then set it to be required. The option group itself will take care of only being able to select one of the check boxes. To make it required, you would just set the values of the options to be 1 through 4 and then set the validation rule on the option group control to be 1 - 4. This will make the control require a value and it won't allow the form to go to another record or close without a prompt. A custom prompt can be entered in the validation text property.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Why not use radio buttons?

      Comment

      Working...