Home

Buttons and List-Based Controls

 

The Command Buttons

 

Introduction

A command button is an object that allows a person to use 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 Design tab of the Ribbon and click the desired section of the form. If the Use Control Wizard option is on Use Control Wizard, the Command Button Wizard would start to help you create a fully functional button. If you don't want to use the wizard, you can click Cancel on the first page of the Command Button Wizard. Also, if you don't want to use the wizard, in the Controls section of the Design tab of the Ribbon, click the More button and click the Use Control Wizards option to dimisss it Use Control Wizard.

Practical Learning: Creating Command Buttons

  1. Start Microsoft Access
  2. Open the Danilo Pizza from the previous lesson
  3. In the Navigation Pane, under the Forms bar, right-click PizzaOrders1 and click Design View
  4. Right-click the form and click Form Header/Footer
  5. In the Controls section of the Ribbon, click the More button More and click the Use Control Wizards to set it on Use Control Wizard
  6. Click the Button Button and click the empty area under the Form Footer bar of the form
  7. On the first page of the Command Button Wizard, in the Categories list, click Form Operations
  8. In the Actions list, click Close Form
     
  9. Click Next
  10. On the second page, replace the content of the Text edit box with Close
     
  11. Click Next
  12. Change the name of the button to cmdClose

  13. Click Finish
  14. Resize the button as you see fit
  15. Switch the form to Form View
     
    Danilo Pizza
  16. To preview the form, right-click its tab and click Form View
  17. 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 properties), and size (Width and Height properties). 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.

Microsoft Office Access 2010 brought new features to the design and appearance of a button. Once of the aspects you can control on the appearance of a button is its shape. To set it, while the form or report is in Design View and the button(s) is(are) selected, on the Ribbon, click Format. In the Control Formatting section, click Change Shape:

Shape

From there, click the desired shape.

Another aspect you can control on a button is its style. To use it, while the form or report is in Design View and the button(s) is(are) selected, on the Ribbon, click Format. In the Control Formatting section, click Quick Style:

Quick Style

From there, click the desired shape.

Combo and List Boxes

 

Combo Boxes

A combo box is a Windows control made of two parts: a text portion and a list. The text box portion 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 tasks 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 an item 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 don't 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. Open the Bethesda Car Rental1 database
  2. 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)
  3. After viewing the form, to switch it, right-click its title bar and click Design View
  4. In the Controls section of the Ribbon, click the More button More and make sure the Use Control Wizards option is on Use Control Wizard.
    To create a list box, on the Ribbon, click the List Box button List Box
  5. Click the form
     
    List Box Wizard
  6. On the first page of the List Box Wizard, make sure the first radio button is selected and click Next
  7. On the second page of the wizard, in the list of tables, click Table: CarCategories
     
    List Box Wizard
  8. Click Next
  9. On the third page of the wizard, in the Available Fields list, click the select all button
     
    List Box Wizard
  10. Click Next 
  11. On the fourth page of the wizard, accept the defaults and click Next
     
    List Box Wizard
  12. On the fifth page of the wizard, make sure the Hide Key Column check box is checked and click Next
  13. Change the label to Rental Rates by Category and click Finish
  14. On the form, make sure the list box selected or click it.
    In the Properties window, click the All tab and click Name
  15. Type lstRentalRates and press Enter
  16. Set the Column Heads property to Yes
  17. Change the Column Widths as follows: 0";0.875";0.85";0.85";0.85";0.85"
  18. Resize the list box control and the form appropriately
     
  19. Save and preview the form
     
    Rental Rates
  20. Close the form
       

Radio Buttons

 

Introduction

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 Navigation Pane, in the Pizza Orders section, right-click Pizza Orders2 and click Design View
  3. On the Ribbon, click the More button More and make sure the Use Control Wizards option is on Use Control Wizard.
    In the Controls section, click the Option Group control Option Group
  4. On the form, click under the Order ID label (you will adjust it later anyway):
     
    Danilo Pizza
  5. On the first page of the option Group Wizard dialog box, click the empty box under Label Names and type Small
  6. Press the down arrow key and type Medium
  7. Press the down arrow key, type Large
     
    Option Group Wizard
     
  8. Click Next
  9. To set the default choice, click the arrow of the combo box and select Medium
     
  10. Click Next
     
     
  11. Accept the values suggested for the option buttons and click Next 
  12. 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
     
  13. Click Next
     
  14. Accept to have the Options Buttons with an Etched border and click Next
  15. Change the Caption suggested to Pizza Size
  16. 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 Pizza Orders2 form in Design View.
    On the form, click the button at the intersection of the rulers 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
     
    Danilo Pizza
  6. Save the form (you can preview it if you want, and switch it back to Design View) 

Check Boxes

 

Introduction

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

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 Pizza Orders2 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 chkPepperoni 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):

 

Check Box

Check Box

Check Box

Practical Learning: Using Check Boxes

  1. To display the Field List, on the Ribbon, click Add Existing Fields 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
     
    Danilo Pizza
  5. Save the form
  6. Preview the form
     
    Danilo Pizza
  7. Close the form

Toggle Buttons

 

Introduction

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 Toggle Button 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.

   
 

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