A radio button is a control that appears in a group with
other radio buttons so that the user can click one of the buttons to
activate it. This action de-activates the other radio buttons of the same
group. This is referred to as mutual exclusivity.

Database: Sweet Star Clothiers

The following database is a fictional company that
creates or sows clothes (various types). The company employs three categories of people,
especially with regards to their pay:

Permanent or full-time employees have a fixed salary that doesn't change
(except in exceptional circumstances that we will not consider here)

Hourly Contractors: These are employees paid on an hourly basis

Piecework Workers: These are also contractors but their pay is based on
what they produce, in this case the number of clothes an employee produces
or sows. In our example, we will use the following table:

Clothes Sown

Price

Between 1 and 60

20.25 each

From 61 to 88

The first 60 at 22.22 eachThe others at 22.18

More Than 88

The first 60 at 24.22 eachBetween 61 and 88 at 24.06 eachThe others at 26.648

Practical Learning: Introducing Radio Buttons

Start Microsoft Access

Click Blank Desktop Database

Set the file name as Sweet Star Clothiers

Click Create

On the Ribbon, click File and click Options

In the left list of the Access Options dialog box, click Current
Database

In the main list, click Overlapping Windows

Click OK on the dialog box

Click OK on the message box

On the Ribbon, click Close

In the list of files, click Sweet Star Clothiers

On the Ribbon, click Create and, in the Forms section, click Form Design

There are various ways to get a radio button or a group of
radio buttons to a form or report. The easiest way is to start by adding an
Option Group and use its wizard. The wizard allows you to create a list of items
that will later be converted into radio buttons. Another technique is to click
the Option Button
from the Controls section of the Ribbon and click inside
a container such as a group box on a form or report.

Characteristics of Radio Buttons

The Option Value of a Radio Button

In Microsoft Access, the radio buttons are considered a
collection of controls that belong to a group box. In the collection of radio buttons, each of them uses an index. This index is
represented by a property named Option Value. The first radio button (or rather one of the
radio buttons in the group) has an index or Option Value of 1, the third (or another)
has an index or Option Value of 2, and so on.

If you use the Option Group Wizard to create the radio buttons, the
wizard automatically creates those
numbers and allows you to change them in the second page of the wizard, which you shouldn't change unless you have a group reason. If you manually add the radio buttons (using the Option Button
), you must then specify the Option Values yourself.

Practical
Learning: Introducing Option Values

In the Controls section of the Ribbon, click the Option Group control
and click the Detail section of the form

In the first page of the wizard, click the cell below Label Names and
type Fixed Salary

Press the down arrow key and type Hourly Salary

Press the down arrow key and type Piecework Pay

Click Next

In the second page of the wizard, click No, I don't want a default

Click Next

Click Next

Click Next

Click Finish

On the Ribbon, click Create and, in the Forms section, click Form Design

In the Controls section of the Ribbon, click the Option Group control

Draw a large rectangle in the Detail section of the form.
If a wizard starts, click Cancel

In the Controls section of the Ribbon, click the Option Button

On the form, click inside the group box.
In the Property Sheet, make sure the Option Value is set to 1

In the Controls section of the Ribbon, click the Option Button
and click inside the group box on the form.
In the Property Sheet, make sure the Option Value is set to 2

In the Controls section of the Ribbon, click the Option Button
and click inside the group box on the form.
In the Property Sheet, make sure the Option Value is set to 3

In the Navigation Pane, right-click the Employees table and click Design
View

Change the
fields as follows:

Field Name

Field Size

Format

Caption

EmployeeID

Employee ID

EmployeeNumber

12

Employee #

FirstName

25

First Name

LastName

25

Last Name

Title

50

PayCategory

Pay Category

HourlySalary

Fixed

Hourly Salary

YearlySalary

Fixed

Yearly Salary

Save and close the table

In the Navigation Pane, right-click the Payrolls table and click Design
View

Change the
fields as follows:

Field Name

Field Size

Format

Caption

PayrollID

Payroll ID

PayDate

Long Date

Pay Date

EmployeeNumber

12

Employee #

WorkUnits

40

Work Units

NetPay

Fixed

Net Pay

Save and close the table

Radio Buttons and the Record Source

The radio buttons don't have a Record Source property. That job is left to the group box.
After specifying that property, you can manage the values of the radio buttons.

As mentioned already, the radio buttons are stored in an
integer-based collection where each radio button is recognized by its numeric
index. Therefore, the field that manages the values of a group of control should
be a a natural number. Its data type can be a Byte, an Integer, or a Long type.
In the records, each value will correspond to a radio button.

Practical Learning: Setting the Record Source of Radio Buttons

Make sure the Employees form is displaying in the Design View.
Double-click the Properties button of the form

In the Property Sheet, set the Record Source of the form to Employees

On the form, click the border of the group box

In the Property Sheet, set the Control Source to PayCategory

In the Tools section of the Design tab of the Ribbon, click Add Existing
Fields

In the Field List, click EmployeeID

Press and hold Ctrl

In the Field List, click EmployeeNumber, FirstName, Lastname, Title,
HourlySalary, and YearlySalary

Release Ctrl

Drag the selection to the form

Complete the design of the form as follows:
All text boxes have the Border Color as Blue, Accent 5, Darker 25% (Theme Colors: 9th column, 5th row)

Save and close the Employees form

Complete the design of the Payroll Preparation form as follows:
In the below list of controls, when the Text Box is indicated, the Caption
is for the accompanying label and the Name is for the text box.
All text boxes have the Border Color as Blue, Accent 5, Darker 25% (Theme
Colors: 9th column, 5th row)

Remember that, in Microsoft Access (unlike Win32), radio
buttons rely on their parent the group box for their management. This means
that, when a radio button is clicked, you must refer to the group box to find
out what button was clicked. As a matter of fact, when a radio button is
clicked, it is in fact the group box that fires the On Click event. When a radio
button is clicked, the group box holds the index of that radio button.
Consequently, if you want to know what radio button was clicked, find out the
current value of the group box. To do that, you can use any appropriate
conditional statement (If...ElseIf or Select Case) or function (IIf, Choose, or Switch).

Practical Learning: Clicking Some Radio Buttons

In the Navigation Pane, right-click the Employees form and click Design
View

On the form, click the border of the group box (or option group)

In the Property Sheet, double-click On Click and click its ellipsis
button

Implement the event as follows:

Private Sub PayCategory_Click()
' When a radio button is clicked, find out from the
' option group what radio button was clicked.
' The first radio button has a value of 1,
' the second has a value of 2, and so on
If PayCategory = 1 Then
YearlySalary.Visible = True
HourlySalary.Visible = False
ElseIf PayCategory = 2 Then
YearlySalary.Visible = False
HourlySalary.Visible = True
Else ' If PayCategory = 3 Then
YearlySalary.Visible = False
HourlySalary.Visible = False
End If
End Sub

In the Object combo box, select Form

In the Procedure combo box, select lick On Current, then click its ellipsis
button

A check box is a Windows control that indicates that a value is true or false. You can manually create the control or let Microsoft Access take
care of that. In this latter case, you can create a Boolean column and add/or a check box on a form or report.

To support check boxes, Microsoft Access VBA provides a class named CheckBox.

Database: ESCAPE

ESCAPE, which stands for Eastern Shore Cable and Produced Entertainment is fictitious cable TV and Internet service provider company that operates in
eastern side of the United States. Its customers, or subscribers, purchase either or both cable TV and Internet connections. The company provides its
subscribers with a cable TV box that receives the necessary signal. The company provides various options to the customers. These includes DVR as a feature used
to video-record TV programs. Another option is the Sports Package that includes some exclusive channels. Other options include Foreign Package, Sport Team Package, etc.

When it comes to the Internet services, customers have the option to purchase (and own) a router or lease one from the company. Another option is select a
speed other than the default slow one.

Practical Learning: Introducing Check Boxes

On the Ribbon, click File and click New

Click Blank Desktop Database

In the File Name text box, type ESCAPE (this stands for Eastern Shore Cable and Produced Entertainment)

Click Create

On the Ribbon, click File and click Options

In the left list of the Access Options dialog box, click Current
Database

In the main list, click Overlapping Windows

Click OK on the dialog box

Click OK on the message box

On the Ribbon, click Create and, in the Forms section, click Form Design

In the Property Sheet, click the All tab and change the following characteristics:
Auto Center: Yes
Record Selectors: No
Navigation Buttons: No
Dividing Lines: Yes
Min Max Buttons: Min Enabled

Right-click the body of the form and click Form Header/Footer

Save the form as New Customer Account

Complete the design of the form as follows:

Control

Caption

Name

Other Properties

Label

ESCAPE

Label

Eastern Shore Cable and Produced Entertainment

Line

Border Style: Dashes

Label

New Customer Account

Label

Customer Identification

Back Color: Background 2, Darker 10%

Text Box

Account #:

txtAccountNumber

Text Box

First Name:

txtFirstName

Text Box

Last Name:

txtLastName

Text Box

Address:

txtAddress

Text Box

City:

txtCity

Text Box

County:

txtCounty

Text Box

State:

txtState

Text Box

ZIP Code:

txtZIPCode

Label

Cable TV Services

Back Color: Background 2, Darker 10%

Text Box

Cable TV Basic Fee:

txtCableTVBasicFee

Format: Fixed

Label

Internet Services

Back Color: Background 2, Darker 10%

Text Box

Internet Basic Fee:

txtInternetBasicFee

Format: Fixed

Close the form

When asked whether you want to save it, click Yes

On the Ribbon, click Create and, in the Forms section, click Form Design

In the Property Sheet, click the All tab and change the following characteristics:
Auto Center: Yes
Record Selectors: No
Navigation Buttons: No
Dividing Lines: Yes
Min Max Buttons: Min Enabled

The New Customer Account form should still be opened in the Design View.
In the Controls section of the Ribbon, click the Check Box
and click an unoccupied area of the Detail section of the form

Complete the design of the form as follows:

Control

Caption

Name

Check Box

Uses DVR Service

chkUsesDVRService

Check Box

Uses Sports Package

chkUsesSportsPackage

Check Box

Provides Own Modem

chkProvidesOwnModem

Close the form

When asked whether you want to save, click Yes

In the Navigation Pane, right-click New Customer Bill and click
Design View

Complete the design of the form as follows:

Control

Caption

Name

Check Box

DVR Service

chkIncludesDVRService

Check Box

Sports Package

chkIncludesSportsPackage

Check Box

Leasing Modem

chkIncludesModemLease

Save the form

Characteristics of a Check Box

The Control Source of a Boolean Field

If you want to link a check box to a column of a table, in its Property Sheet, set its Control Source to that column. If you are
programmatically creating the control, pass the name of the table as the fourth argument and the name of the column as the fifth argument. Here is an example:

To perform data entry on a check box, the user can check or uncheck it. To programmatically specify the value of a check box, access its
Value property and assign True or False to it. Here is an example:

Private Sub cmdIsMarried_Click()
chkIsMarried.Value = True
End Sub

If you set the value to True, the control would display a check mark. If you set it to False, the check box would be emptied.

Boolean Data Entry With the SQL

To specify the value of a Boolean field during data entry, set its value to 0 or 1. Here are examples:

If you set the value to 0, the field receives a value of false, which is the same as the check box being empty. If you set the value to 1,
the field is considered true. In your code, you can also specify the value as True or False. Here are examples:

To help you find out the state of a check box, its
class is equipped with a Boolean property named Value. When it is False or 0, the check box is empty or unchecked. When the Value is True or -1, the control is checked.
Because this is the default property, you can omit it when accessing the check
box.

Practical Learning:
Using the Value of a Check Box

The New Customer Bill form should still be opened in the Design View.
In the Tools section of the Design tab of the Ribbon, click the View Code button

In the Navigation Pane, right-click the New Customer Account form and
click Design View

Introduction to Toggle Buttons

Overview

A toggle button is a variant of a command button, a radio button, and a check box. This means that a toggle
button has the ability to behave like any of those controls. In Microsoft Windows (that is, in Win32), the toggle button is created by
setting some of the characteristics of either the radio button or the check box.

Creating a Toggle Button

Microsoft Access has its own support of the toggle button with a formal control of that name.
In Microsoft Access, the toggle button is managed by a class named ToggleButton.

In the Microsoft Access database environment, the way you create a toggle button depends on how you are planning to use it. To create a toggle button that will behave like a general button, display a form or report in the Design View
(it is not particularly useful to add a toggle button to a report). In the Controls section of the Ribbon, click the Toggle Button control and click the form
(or report).

Characteristics of Toggle Buttons

The Caption of a Toggle Button

Most of time, the toggle button doesnít use a caption. Still, if you want it to indicate what it is used for, you can add a caption to it. This is managed by the
Caption property.

Toggle Buttons as a Group of Radio Buttons

Toggle buttons can be used in a group like radio buttons.
You create the group as it is done for radio buttons. If you click the Option
Group button from the Controls section of the Ribbon and click a form (or
report) in the Design View, a wizard may start. The fourth page of the wizard is
the real difference. This is where you should click the Toggle Buttons option.

You can create a group of toggle buttons without using a wizard. To do this, from the Controls section of the Ribbon, click the Option Group button and click a form in the Design View. If the wizard starts, click Cancel. In the Controls section of the Ribbon, click the Toggle Button control and click inside the group box on the form. Add as many toggle buttons as you need. You can create a group of toggle buttons without using a wizard. To do this, from the Controls section of the Ribbon, click the Option Group button and click a form in the Design View. If the wizard starts, click Cancel. In the Controls section of the Ribbon, click the Toggle Button control and click inside the group box on the form. Add as many toggle buttons as you need.

If you create a group of toggle buttons, as mentioned for radio buttons, they are managed by the group box that in fact holds their common Control Source. As a result, when one of the toggle buttons is clicked, to find out which one is active, get the Value property of the group box. To specify one of the toggle buttons is primarily clicked, set the Default Value of the group box.

Practical Learning: Introducing
Toggle Buttons

In the Controls section of the Ribbon, click the Option Group control
and click an unoccupied area in the Detail section of the form

In the first page of the wizard, click the cell below Label Names and
type Starter

Press the down arrow key and type Blast

Press the down arrow key and type Extreme

Click Next

In the second page of the wizard, accept the first radio button to have
Starter as the default choice and click Next

In the third page of the wizard, accept the suggested label named and
values of the options. Click Next

In the fourth page of the wizard, click Toggle Buttons

Also click Shadowed

Click Next

Click Finish

Change the Name of the group box to fraInternetSpeedApplied

Change the caption of the accompanying label to Speed Requested

Position the group box and its toggle buttons at the bottom of the form.
Position the toggle buttons horizontally:

Control

Caption

Name

Option Group

Speed Requested

fraInternetSpeedApplied

Save the form

A Toggle Button like a Check Box

As mentioned above, when creating or a group of toggle buttons, you should know how you are planning to use it. If you want to use it as a check box, add it to a form or a rectangle. In this case,
the toggle button would be equipped with a Control Source property that you can use to bind the control to a
field of a table, query, or SQL expression.

A toggle button that is created to behave like a check box
has the same properties and events as the check box.

When the toggle button is clicked, to let you get its state,
use its Value property. When the toggle value is displaying normally, which is equivalent to an empty check box, the Value of the toggle button is 0. When the control is clicked, its value becomes -1. At any time, to find out the state of the toggle button, you can inquire about its Value.

To let you specify how the toggle button should primarily display, the control is equipped with the Default Value property.

The Background Colors of a Toggle Button

A toggle button added directly to a form, to a report, or inside a rectangle behaves, by default, like a check box. This means that it first comes up with a default color (deep blue, close to Navy). When clicked, its changes its appearance to a light blue color. As mentioned for command buttons, you can specify what color should paint the toggle button:

When the button is normally resting. This is the role of the Back Color property

When the mouse is passing or positioned over the control. Thatís the role of the Hover Color property

When the button is clicked and while the mouse is held down on it. This is managed by the Pressed Color property