Overview of Windows Controls


The Command Buttons



A command button is a rectangular object that allows the user to dismiss a dialog box or to initiate an action. This is done through a decision making process based on what a form is displaying. This could be an acknowledgement, such as a form displaying a simple message to the user. A user could also be asked to choose one button from a group of buttons on a form.

To use a button, the user positions the mouse on the desired button and presses the left button. This action is referred to as clicking.

Depending on how the button is implemented, it should be obvious to the user what to do with it. To indicate what a button is used for or what action it would lead to, a button can display a string on its top.

This string is also referred to as the button's caption. The caption should be explicit enough to let the user know what the button is used for. A caption like OK usually means the user accepts what message the form is displaying. A caption like Cancel is usually accompanied by an OK button.

When a button has a Cancel button, the user would usually click it as if saying, "Never Mind" or "I change my mind", etc.

To create a button, you can click the Button Button in the Controls section of the Ribbon and click the desired section of the form. On the Ribbon, if the Use Control Wizard button was down or clicked Use Control Wizard, the Command Button Wizard would start to help you create a fully functional button. If you do not want to use the wizard, you can click Cancel on the first page of the Command Button Wizard. Also, if you do not want to use the wizard, on the Ribbon, you can click the Use Control Wizards button to have it up Use Control Wizard.

Practical Learning: Creating Command Buttons

  1. Open the Bethesda Car Rental1 database
  2. Open the Assets form in Design View
  3. In the Controls section of the Ribbon, click the Use Control Wizard button or make sure it is highlighted Use Control Wizard.
    Click the Button Button and click the empty area under the Form Footer bar of the form
  4. On the first page of the Command Button Wizard, in the Categories list, click Form Operations
  5. In the Actions list, click Close Form
  6. Click Next
  7. On the second page, replace the content of the Text edit box with Close
  8. Click Next
  9. Change the name of the button to cmdClose and click Finish
  10. Resize the button as you see fit
  11. Switch the form to Form View
  12. Click the Close button to close the form. If/when asked whether you want to save it, click Yes

Characteristics of Command Buttons

Like all other “visual” controls, a button has a Name property, a location (Left and Top), and size (Width and Height). Because of their anticipated behavior, buttons are the most commonly used objects to initiate an action. As such, they are used to open forms or reports or to display message boxes.

As we saw in the second page of the wizard, a command button in Microsoft Access can display either a string or a (small) picture on top. Microsoft Access ships with dozens of pictures you can use, especially made for buttons. If none of these pictures suits your need, you can design your own. To display a picture on a button, after selecting it in Design View, click the ellipsis button of the Picture field in the Format tab of the Properties window, locate the picture, and select it.

When a dialog box is equipped with an OK and a Cancel button, it is suggested that the user be able to press Enter to perform the same action as if he had clicked OK. To apply this behavior, if you create a button and give it an OK caption, you can set its Default property to Yes. It is also suggested that, if a button has a Cancel Caption, the user should be able to press Esc and produce the same behavior as if the Cancel button was clicked. To apply this feature, after creating the button with a Cancel caption, set its Cancel property to Yes. Never set the Default and the Cancel properties both to Yes for the same button.

Combo and List Boxes


Combo Boxes

A combo box is a Windows control made of two parts: a text portion and a list. A text box is used to display a selection made from a list of items. On the right side of the text box, there is a down-pointing arrow that allows the user to know that the control holds a list. The user displays the list by clicking the arrow:

To use a combo box, the most basic operation the user can perform is to click the arrow and select an item. Once an item is selected, the list retracts back like a plastic.

There are various ways you can add a combo box to a form or report: using the Lookup Wizard or using the Combo Box Wizard:

The combo box is one of the highly praised features of Microsoft Access. As the application makes it particular easy to create, it performs all necessary basic behind-the-scene jobs. The Combo Box Wizard, used to create a bound combo box, is able to reconcile a relationship between two tables. After creating the combo box, especially if you used the wizard to configure it, you can check and adjust the characteristics as you see fit.

Like every control, a combo box uses a name that allows the database application or the operating system to identify it. If you create a combo box by dragging, from the Field List, a field whose lookup features have already been configured, the control would receive the same name as the table’s column. If you create a combo box using the Combo Box Wizard, the control would receive a name that starts with Combo. An example would be Combo21. If you do not intend to refer to the combo box in an expression, you would not need to pay attention to the name of the control. Otherwise, if you create various controls using wizards, the names might become confusing. In this case it would be a good idea to change the name of the combo box. Like all others, to change the name of a control, access its Properties window and, from the Other or the All table, change the value of the Name property.

List Boxes

A list box presents a list of items to the user. The list appears as a taller text box. The items in the list appear each on its own line. The user makes a selection by clicking in the list. Once an item is clicked, it becomes highlighted indicating that it is the current choice:

Probably the easiest way to create a list is by using the List Box Wizard. This allows you to select the source of data, which would be a table or a query. Then you can select the column that would be displayed as the value of the list box, exactly as done for the combo box.

When we think of a list box, we usually assume that it is made of one column of items. A list box can be made of various columns. In this case, it is sometimes called a list view. Most of the time, when a multi-column list displays, the user may not be able to identify the items under each column. In this case, you can display a column header on its column. This column header would display a label that categorizes the items under it.

One of the main reasons for using a combo or a list box is to provide a list of items to the user. Sometimes the list would be very large. If the list is long, the control would provide a vertical scroll bar that allows the user to navigate up and down to access all items of the list. The database developer decides how many items to display in the list.

Practical Learning: Configuring a Combo Box

  1. The Bethesda Car Rental1 database should still be opened.
    In the Navigation Pane, double-click Rental Rates to open it (you should have created this dialog box in Lesson 8; if you did not, use the Rental Rates1 dialog box)
  2. After viewing the form, switch it to Design View
  3. In the Controls section of the Ribbon, make sure the Use Control Wizard button is down Use Control Wizard.
    To create a list box, on the Ribbon, click the List Box button and click the form
  4. On the first page of the List Box Wizard, make sure the first radio button is selected and click Next
  5. On the second page of the wizard, in the list of tables, click Table: CarCategories and click Next
  6. On the third page of the wizard, in the Available Fields list, click the select all button
  7. Click Next 
  8. On the fourth page of the wizard, accept the defaults and click Next
  9. On the fifth page of the wizard, make sure the Hide Key Column check box is checked and click Next
  10. Change the label to Rental Rates by Category and click Finish
  11. Preview the form in Form View and switch it back to Design View
  12. On the form, click the list box to select it
  13. In the Properties window, click the All tab. Click Name. Type lstRentalRates and press Enter
  14. Set the Column Heads property to Yes
  15. Change the Column Widths as follows: 0";0.875";0.85";0.85";0.85";0.85"
  16. Resize the list box control and the form appropriately
  17. Save and preview the form
    Rental Rates
  18. Close the form

Radio Buttons



A radio button is a Windows control made of a round box O. In practical usage, a radio button is usually (if not always) accompanied by other radio buttons. In other words, radio buttons come as a group. The user makes a decision by selecting or clicking one of the round boxes. Once clicked, the round box is partially filled with a dot. When one button in the group is selected, the other round boxes of the (same) group are empty O. The user can select another button by clicking a different choice, which empties the previous selection. This technique of selecting is referred to as mutually-exclusive.

There are two main ways you add a radio button to your form or report. While in Design View, if you add an Option Group control to a window while the Control Wizard button is down, the Option Group Wizard would start, allowing you to create a list of items where each item would be later converted into a radio button. If the radio button must be linked to a column of the data source, you will need to specify it. Such a column should have a natural number as data type (Byte, Integer, Long Integer).

Practical Learning: Adding Radio Buttons

  1. Open the Danilo Pizza1 database
  2. In the PizzaOrders section of the Navigation Pane, Under PizzaOrders: Table, double-click PizzaOrders (the form) to open it
  3. After viewing the form, to switch it to Design View, right-click its tab and click Design View
  4. On the Ribbon, make sure that the Use Control Wizards button is highlighted Use Control Wizard.
    In the Controls section, click the Option Group control Option Group
  5. On the form, click under the Order ID label (you will adjust it later anyway).
    If you receive a Microsoft Office Access Security Notice, read it and click Open
  6. On the first page of the option Group Wizard dialog box, click the empty box under Label Names and type Small
  7. Press the down arrow key and type Medium
  8. Press the down arrow key, type Large
    Option Group Wizard
  9. Click Next
  10. To set the default choice, click the arrow of the combo box and select Medium
  11. Click Next
  12. Accept the values suggested for the option buttons and click Next 
  13. Click the arrow of the combo box and select PizzaSize (because the option button selected will be held by, or carried by, or stored in, the PizzaSize field)
    Option Group Wizard
  14. Click Next
  15. Accept to have the Options Buttons with an Etched border and click Next
  16. Change the Caption suggested to Pizza Size and click Finish

Properties of Radio Buttons

Because the round box of a radio button does not indicate what it is used for, it is usually (if not always) accompanied by a label. The label can be positioned anywhere (to the left, the top, the right, or the bottom side) close to the round box but it is usually positioned to the left or the right side. To move or position the round box, click it to select it. Then position your mouse on it to get a 4-arrow cross and drag in the desired direction:

Like most (if not all) other controls, when you include a radio button, Microsoft Access adds a label to the control. If you do not like the string displayed by the label, you can click it twice to put it into edit mode and change the string.

Practical Learning: Configuring Radio Buttons

  1. The Danilo Pizza1 database should still be opened with the PizzaOrders form in Design View.
    On the form, click an unoccupied area to make sure nothing is selected
  2. Double-click the border of the newly added Group Box (the line that surrounds the group and touches the Pizza Size label) to select the frame
  3. In the Properties window, click the Other tab and click Name
  4. Type fraPizzaSize and press Enter
  5. Enlarge the border of the option group to include the text boxes that correspond to the option buttons
  6. Save the form (you can preview it if you want, and switch it back to Design View) 

Check Boxes



A check box is a control that allows the user to validate or invalidate an option. A check box appears as a little square box. The user makes a decision by clicking in the square, which puts a check mark in the square. Toggling means, that if the square box were empty, after clicking it, a check mark would appear in it.

Although it can appear by itself, a check box can come in a group with others, allowing the user to select as many choices as are available, as opposed to radio buttons where only one in the group can be selected

Check boxes provide a non-exclusive choice, which means that if they come as a group, each behaves independently with regards to the other check boxes of the same group. Therefore you can create check boxes anywhere on the form or report. It is recommended that, when they act as an ensemble, you should include check boxes in a group so their belonging to the same group would be obvious to the user.

To add a check box to a form or report, in the Controls section of the Ribbon, click the Check Box Check Box and click the form or report where you want to position the control.

Practical Learning: Adding a Check Box

  1. The Danilo Pizza1 database should still be opened with the PizzaOrders form in Design View.
    In the Controls section of the Ribbon, click the Check Box control Check Box and click the group box under the Toppings label
  2. While the new check box is still selected, in the Properties window, click the All tab and click Name. Type txtPepperoni and press Enter
  3. In the Control Source, select Pepperoni
  4. On the form, click the label of the new check box. Click it again and edit its string to display Pepperoni

Characteristics of Check Boxes

As mentioned already, when you add a check box to a form or report, it is accompanied by a label positioned to its right. The label is used to indicate what the check box is used for, but the label can be moved or even removed from the host. That is, the label can be treated independently.

If you click the check box itself, it becomes surrounded by an orange box. Although you can resize that orange box, you cannot resize the actual check box: it is managed by the operating system.

A check box is used to express a Yes/No value (also called a Boolean value) as true or false. Sometimes, the decision cannot be made as a definite true or a definite false. To support this eventuality, a check box can assume an intermediate (or indeterminate) value. To provide this functionality, the check is equipped with a property named Triple State. This property is Boolean. If it is set to Yes, the check box can be true (checked), undetermined (dimmed), or false (unchecked):


Practical Learning: Using Check Boxes

  1. To display the Field List, on the Ribbon, click Add Existing Fields
  2. From the Field List, drag Sausage and drop it in the group box under the Toppings label
  3. In the same way, drag the ExtraCheese, the Onions, and the Olives fields to the same group box
  4. Using the techniques of control resizing and moving, complete the design of the controls as you see fit
  5. Save, preview, and close the form

Toggle Buttons



A toggle button is a type of button that behaves like a check box. It displays like a command button but behaves like a check box. Also, while a check box should be accompanied by a label that indicates what the check box is used for, a toggle button, like the command button, can display a string on its “face”.

To create a toggle button, you can click the Toggle Button control in the Controls section of the Ribbon and click the form. Like the check box and the radio buttons, there is no wizard to follow.

Properties of a Toggle Button

Configuring the toggle button is particularly easy. Like the check box, the toggle button should be used for a Boolean field. Therefore, after adding it to a form, in the Control Source of the toggle button, select the field that would carry or show its value.

Lessons Summary


MCAS: Using Microsoft Office Access 2007 Topics  
C7 Modify the design of reports and forms

Previous Copyright © 2008-2016, FunctionX, Inc. Next