Use a check box or other control to display a Yes/No value

In Access, a Yes/No field stores only two values: Yes or No. If you use a text box to display a Yes/No field, the value displays as -1 for Yes and 0 for No. These values are not very meaningful for most users, so Access provides check boxes, option buttons, and toggle buttons that you can use to display and enter Yes/No values. These controls provide a graphic representation of the Yes/No value that is both easy to use and easy to read.

This article describes the applications for each of these controls, and tells you how to add them to your forms and reports.

What do you want to do?


Decide which control to use

For most situations, a check box is the best control for representing a Yes/No value. This is the default type of control that is created when you add a Yes/No field to a form or report. By contrast, option buttons and toggle buttons are most often used as part of an option group. For more information about option groups, see the section Understand option groups.

The following illustration shows the three controls and how they represent Yes and No values. The Yes column shows the control as it appears when selected, and the No column shows the control as it appears when cleared.

Yes/No controls

Top of Page Top of Page

Create a bound check box, option button, or toggle button

You can quickly create a check box by dragging a Yes/No field from the Field List pane to the form or report.

  1. Open the form or report in Layout view or Design view by right-clicking it in the Navigation Pane, and then clicking the view you want on the shortcut menu.
  2. If the Field List pane is not already displayed, press ALT+F8 to display it.
  3. Expand the table lists, if needed by clicking the plus signs (+) next to the table names.
  4. Drag the Yes/No field from the Field List pane to the form or report.

Depending on the setting of the field's Display Control property, a check box, a text box, or a combo box is created and bound to the field. When you create a new Yes/No field in a table, the default setting of the field's Display Control property is Check Box.

If you want, you can change the check box control to an option button or a toggle button. To do this, right-click the check box, point to Change To on the shortcut menu, and then click Toggle Button Button image or Option Button Button image.

Top of Page Top of Page

Create an unbound check box, option button, or toggle button

You can use an unbound check box, option button, or toggle button in a custom dialog box to accept user input and then carry out an action based on that input.

  1. Open the form or report in Design view by right-clicking it in the Navigation Pane, and then clicking Design View on the shortcut menu.
  2. On the Design tab, in the Controls group, click the tool for the control you want (Check Box Button image, Option Button Button image, or Toggle Button Button image ).
  3. Click on the form or report where you want to place the control.

Access places the control on the form or report.

Although it is not required, you might want to rename the control so that it has a more meaningful name. Doing so does not change the label displayed next to the control, but it can make it easier to refer to it in expressions (expression: Any combination of mathematical or logical operators, constants, functions, and names of fields, controls, and properties that evaluates to a single value. Expressions can perform calculations, manipulate characters, or test data.) or macros (macro: An action or a set of actions that you can use to automate tasks. Macros are recorded in the Visual Basic for Applications programming language.).

Rename the control

  1. Ensure that the control is selected.
  2. If the property sheet is not already displayed, press F4 to display it.
  3. Type a new name in the Name property box of the control.

If you want, you can change the check box to an option button or a toggle button. To do this, right-click the check box, point to Change To on the shortcut menu, and then click Toggle Button Button image or Option Button Button image.

Top of Page Top of Page

Understand option groups

An individual check box, option button or toggle button can be bound or unbound, or it can be part of an option group. An option group displays a limited set of alternatives, and only one option in an option group can be selected at a time. An option group consists of a group frame and a set of check boxes, toggle buttons, or option buttons.

If an option group is bound to a field, only the group frame itself is bound to the field, not the controls contained inside the frame. Instead of setting the Control Source property for each control in the option group, you set the Option Value property of each control to a number that is meaningful for the field to which the group frame is bound. When you select an option in an option group, Access sets the value of the field to which the option group is bound to the value of the selected option's Option Value property.

The value of an option group can only be a number, not text. Access stores this number in the underlying table. An option group can also be set to an expression, or it can be unbound. You can use an unbound option group in a custom dialog box to accept user input and then carry out an action based on that input.

It is a standard practice to use check boxes for Yes/No fields and option buttons or toggle buttons for option groups. However, this is only a suggestion, and you can use any of the three controls for either purpose.

Top of Page Top of Page

Create an option group

You can quickly create an option group by using the Option Group Wizard. Before you begin, decide whether you want the option value to be stored in a table. If so, you must have a field of the Number data type designated for this purpose.

For more information about adding a field to a table, see the article Insert, add, or create a new field in a table.

  1. Open the form in Design view by right-clicking it in the Navigation Pane, and then clicking Design View Button image.
  2. On the Design tab, in the Controls group, ensure that Use Control Wizards Button image is selected. Button image
  1. In the same group, click Option Group Button image.
  2. Click on the form where you want to place the option group.
  3. Follow the instructions in the wizard. On the last page, click Finish.

Access places the option group on the form.

Rename the option group    Although it is not required, you might want to rename the option group so that it has a more meaningful name. Doing so does not change the label displayed next to the option group, but it can make it easier to refer to the control in expressions or macros.

  1. Ensure that the option group is selected by clicking the frame of the group.
  2. If the property sheet is not already displayed, press F4 to display it.
  3. Type a new name in the Name property box of the option group.

Top of Page Top of Page

Add a new option to an existing option group

You can add new option controls to an option group as your needs change. You can either create a new control in the group, or you can cut an existing control from elsewhere on the form and paste it into the group.

  1. Open the form in Design view by right-clicking it in the Navigation Pane, and then clicking Design View Button image.
  2. Click on the frame of the option group to select it, and then drag the frame's sizing handles to make room for the new option control.
  3. Do one of the following:
    • Create a new control in the group    
      1. On the Design tab, in the Controls group, click the tool for the type of control you want to add (Check Box Button image, Option Button Button image, or Toggle Button Button image ).
      2. Move the pointer so that it is positioned inside the frame of the option group. The frame changes color to indicate that the new control will become part of the option group.
      3. Click to place the control in the group.
    • Move an existing control to the group    

Simply dragging a control to an option group does not make it part of the group. You must cut and paste the control into the group for it to become an option.

  1. Select the control that you want to move into the option group.
  2. On the Home tab, in the Clipboard group, click Cut. Button image
  1. Select the option group by clicking the frame that surrounds the group.
  2. On the Home tab, in the Clipboard group, click Paste. Button image

Access adds the control to the group.

  1. You will probably need to move the control and its label so that they line up with the existing controls and labels.
  1. Select the newly-added control, and then press F4 to open the property sheet for the control.
  2. Note the value of the Option Value property of the newly-added control. Depending on your needs, you can leave it at the value Access suggests, or you can change it to a different value.

Top of Page Top of Page

 
 
Applies to:
Access 2010, Access 2007