Home

Button-Based Controls

The Command Buttons

Introduction

A command button is a Windows control that allows a user to perform or initiate an action by clicking it. The caption is the text that displays on the button and it indicates what the button is used for.

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 dimiss it Use Control Wizard.

Practical Learning: Creating a Command Button

  1. Start Microsoft Access
  2. In the list of databases, click Ceil Inn1
  3. In the Navigation Pane, right-click the Employees form and click Design View
  4. In the Controls section of the Ribbon, click the More button More and make sure the Use Control Wizards is set Use Control Wizard.
    Click the Button control Button and click the empty area under the Form Footer bar of the form
  5. On the first page of the Command Button Wizard, in the Categories list, click Form Operations
  6. In the Actions list, click Close Form

    Command Button Wizard

  7. Click Next
  8. On the second page, replace the content of the Text edit box with Close

    Command Button Wizard

  9. Click Next
  10. Change the name of the button to cmdClose

    Command Button Wizard

  11. Click Finish
  12. Resize the button as you see fit

    Ceil Inn - Customers

  13. In the Controls section of the Ribbon, click the Button Button and click the Form Footer section
  14. On the wizard, click Cancel
  15. In the Property Sheet, click the All tab and, click the arrow of the On Click field and select mcrPage1
  16. Still in the All tab of the Property Sheet, change the following characteristics for the button:
    Name: cmdGeneralInformation
    Caption: General Information
  17. In the Controls section of the Ribbon, click the Button Button and click the Form Footer section
  18. On the wizard, click Cancel
  19. To create a macro, in the bottom section of the form, right-click the new button and click Build Event...

    Macro Builder

  20. In the Choose Builder dialog box, make sure Macro Builder and click OK
  21. In the Action combo box, select GoToPage
  22. In the Page Number, type 2
  23. Close the macro window
  24. When asked whether you want to save, click Yes
  25. In the All tab of the Property Sheet, change the following characteristics for the button:
    Name: cmdPaySummary
    Caption: Pay Summary
  26. On the form, right-click the Close button in the Form Footer section and click Copy
  27. Open each form in Design View and paste in the Form Footer section
  28. On the Ribbon, click File and click Open
  29. In the list of databases, click College Park Auto-Repair1 from the previous lesson
  30. When asked whether you want to save, click Yes each time
  31. In the Navigation Pane, right-click the RepairOrders form and click Design View
  32. In the Controls section of the Ribbon, click the Button control Button and click the empty area under the Form Footer bar of the form
  33. On the first page of the Command Button Wizard, in the Categories list, click Form Operations
  34. In the Actions list, click Close Form and click Next
  35. On the second page, replace the content of the text box with Close and click Next
  36. Change the name of the button to cmdClose and click Finish
  37. Close the form
  38. When asked whther you want to save, click Yes
  39. On the Ribbon, click File and click Open
  40. In the list of files, click RoadSystem1
  41. When asked whether you want to save it, click Yes
  42. In the Navigation Pane, right-click the Roads form and click Design View
  43. In the Controls section of the Ribbon, click the Button control Button and click the empty area under the Form Footer bar of the form
  44. On the first page of the Command Button Wizard, in the Categories list, click Form Operations
  45. In the Actions list, click Close Form and click Next
  46. On the second page, replace the content of the Text edit box with Close and click Next
  47. Change the name of the button to cmdClose
  48. Click Finish and resize the button as you see fit
  49. Right-click the button and click Copy
  50. Switch the form to Form View
  51. To preview the form, in the Views section of the Ribbon, click the View button

    Adding a Button to a Form

  52. Close the form
  53. When asked whether you want to save, click Yes

A Picture on a Command Button

As indicated in the second page of the wizard, a command button in Microsoft Access can display either text or a (small) picture on top. Microsoft Access ships with dozens of pictures you can use, specially made for buttons. If none of these pictures suits your need, you can design your own, using any application of your choice. The picture can have any size you want and it should be saved as a bitmap.

To display a picture on a button, after selecting it in Design View, click the ellipsis button Browse of the Picture field in the Format tab of the Property Sheet, locate the picture, and select it.

The OK and Cancel Buttons

When a dialog box is equipped with an OK and a Cancel buttons, 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.

The Style of a Command Button

You can control the appearance and style of a button. To set it, while the form 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

Practical Learning: Specifying the Style of a Button

  1. On the Ribbon, click File and click open
  2. In the list of files, click College Park Auto-Repair1
  3. In the Navigation Pane, right-click the RepairOrders form and click Design View
  4. On the form, click the Close button in the Form Footer section
  5. On the Ribbon, click Format
  6. In the Control Formatting section, click Quick Styles and click Subtle Effect - Black, Dark 1 (1st column - 4th row)

    College Park Auto-Repair - Form Design - Button Quick Style

  7. Close the form
  8. When asked whether you want to save the changes, click Yes
  9. On the Ribbon, click File and click Open
  10. In the list of databases, click FunDS1
  11. In the Navigation Pane, right-click the Employees form and click Design View
  12. In the Controls section of the Ribbon, click the Button control Button and click the empty area under the Form Footer bar of the form
  13. On the first page of the Command Button Wizard, click Form Operations and click Close Form
  14. Click Next
  15. On the second page, replace the content of the Text edit box with Close and click Next
  16. Change the name of the button to cmdClose and click Finish
  17. On the Ribbon, click Format
  18. In the Control Formatting section, click Quick Styles and click Insense Effect - Orange, Accent 2 (3rd column - 6th row)

    Specifying the Style of a Button

  19. Right-click the button and click Copy
  20. In the Navigation Pane, right-click the ShoppingSessions form and click Design View
  21. Right-click in the Form Footer section and click Paste
  22. In the Navigation Pane, right-click the StoreItems form and click Design View
  23. Right-click in the Form Footer section and click Paste
  24. On the Ribbon, click File and click Open
  25. In the list of databases, click Altair Relators1
  26. When asked whether you want to save, click Yes every time

The Shape of a Command Button

Another aspect you can control on a button is its shape. To apply it, while the form 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.

Practical Learning: Specifying the Shape of a Button

  1. In the Navigation Pane, right-click the Properties form and click Design View
  2. In the Controls section of the Ribbon, click the Button control Button and click the empty area under the Form Footer bar of the form
  3. On the first page of the Command Button Wizard, in the Categories list, click Form Operations
  4. In the Actions list, click Close Form and click Next
  5. On the second page, replace the content of the Text edit box with Close and click Next
  6. Change the name of the button to cmdClose and click Finish
  7. On the Ribbon, click Format
  8. In the Control Formatting section, click Change Shape and click Oval
  9. Resize the button as you see fit

    Specifying the Shape of a Button

  10. On the Ribbon, click File and click Open
  11. In the list of files, click RoadSystem1
  12. When asked whether you want to save it, click Yes
  13. In the Navigation Pane, right-click the Roads form and click Design View
  14. In the Controls section of the Ribbon, click the Button control Button and click the empty area under the Form Footer bar of the form
  15. On the first page of the Command Button Wizard, in the Categories list, click Form Operations
  16. In the Actions list, click Close Form and click Next
  17. On the second page, replace the content of the Text edit box with Close and click Next
  18. Change the name of the button to cmdClose
  19. Click Finish and resize the button as you see fit
  20. Right-click the button and click Copy
  21. Switch the form to Form View
  22. To preview the form, in the Views section of the Ribbon, click the View button

    Adding a Button to a Form

  23. Open each form in Design View and paste in the Form Footer section
  24. On the Ribbon, click File and click Open
  25. In the list of files, click Ceil Inn2
  26. When asked whether you want to save, click Yes
 
 
 

Radio Buttons

Introduction

A radio button, also called an option button. is a Windows control made of a round box. 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 clicking one of the round boxes. There are two main ways you can create radio buttons. You can follow the indications from a wizard (which is usually the easier way) or you can manually add the radio buttons.

Before adding radio buttons to your form or report, you must first add a container. To do this, you can use the Option Group control Option Group. If a wizard comes up, click Cancel.

To add a radio button to a form or report, in the Controls section of the Ribbon, click the Option Button Option Button and click inside the target container on the form or report. 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. When you include a radio button, Microsoft Access adds a label to it, to its right. You can change the position of the label to anywhere (to the left, the top, the right, or the bottom side) you want, close to the round box. If you don't like the text of the label, you can change or edit it.

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.

Characteristics of Radio Buttons

If you want to create a group of radio buttons that are tied to a table, in the table, you must create a column that has a natural number as data type.

Because radio buttons work as a group, it is their group box container, not each radio button, that is tied to the column of the table. This means that, after adding an group box to a form or report, set its Record Source to the column of the table.

In the Property Sheet, a radio button has a property named Default Value. This is an incremental value that must be different for each radio button in the group. The first, top or left radio button should have a value of 1, the second should have a value of 2, and so on.

Practical Learning: Adding Radio Buttons

  1. On the Ribbon, click File and click Open
  2. In the list of files, click Ceil Inn1
  3. From the Navigation Pane, open the Employees form

    Characteristics of Radio Buttons

  4. Switch the form to Design View
  5. In the Controls section of the Ribbon, click the Option Group control Option Group
  6. In the form, click under the Title text box.
    If a wizard comes up, click Cancel
  7. In the Property Sheet, click the All tab and change the following characteristics:
    Name: fraMaritalStatus
    Record Source: MaritalStatusID
  8. Click the label in the top section of the group box
  9. In the Property Sheet, change the following characteristics:
    Name: lblMaritalStatus
    Caption: Marital Status
  10. In the Controls section of the Ribbon, click the Option Button Option Button and click inside the option group you had added to the form
  11. In the Property Sheet, change the following characteristics:
    Name: optSingle
    Option Value: 1 (it should be set already)
  12. Click the label next to the radio button
  13. In the Property Sheet, click Caption and type Single
  14. In the Controls section of the Ribbon, click the Option Button Option Button and click inside the option group you had added to the form
  15. In the Property Sheet, change the following characteristics:
    Name: optMarried
    Option Value: 2 (it should be set already)
  16. Click the label next to the radio button
  17. In the Property Sheet, click Caption and type Married
  18. Save the form

Automatically Generating a Group of Radio Buttons

 Microsoft Access provides a means of easily creating a group of radio buttons. This done by following the Option Group Wizard. To use the wizard, make the Use Control Wizard button is on Use Control Wizard. Among the advantages of using the wizard, it creates the captions of the buttons (you provide the texts), it creates the default value for each radio button, it allows you to select the radio button, and finally it proportionately positions the radio buttons inside the group box.

Practical Learning: Introducing the Group Box

  1. In the Controls section of the Ribbon, click the Option Group control Option Group
  2. Click an unoccuppied area of the form
  3. In the first page of the wizard, type: Unknown and press the down arrow key
  4. Type: Head of Household and press the down arrow key
  5. Type : Married Filing Jointly

    Option Group Wizard

  6. Click Next

    Option Group Wizard

  7. Accept the dialog box and click Next

    Option Group Wizard

  8. In the dialog box, click the arrow of the combo box and select FilingStatusID

    Option Group Wizard

  9. Click Next
  10. Click Next
  11. In the Caption, type Filing Status

    Option Group Wizard

  12. Click Finish
  13. On the form, click Marital Status
  14. Press and hold Shift
  15. Click Filing Status
  16. Release Shift
  17. In the Property Sheet, click Format and change the following characteristics:
    Back Color: Text 2, Lighter 60%
    Font Name: Constantia (if you don't have that font, select Georgia)
    Border Color: Accent 1, Darker 50%
    Fore Color: Background 1
  18. On the form, select all labels close each radio button (you can click one of them, press and hold Shift, then click each label, and release Shift)
  19. In the Format tab of the Property Sheet, change the following characteristics:
    Font Name: Constantia (if you don't have that font, select Georgia)
    Fore Color: Text 1
  20. Set the Special Effect of all radio buttons to Flat
  21. Design the form as you see fit. Here is an example:

    Adding Option Groups to a Form

  22. Right-click somewhere in the Detail section of the form and click Tab Order
  23. In the Tab Order dialog box, click Auto Order
  24. Click OK
  25. Preview the form

    Adding Option Groups to a Form

  26. Save the form

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.

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. On the Ribbon, click File and click Open
  2. In the list of files, click Altair Realtors1
  3. In the Navigation Pane, right-click the Properties table and click Design View
  4. Click the first empty cell under Field Name
  5. Type FinishedBasement and press Tab
  6. Click the arrow of the Data Type combo box and select Number
  7. In the bottom section of the window, click Caption and type Finished Basement
  8. To switch the table, in the Design tab of the Ribbon, in the Views section, click the View button
  9. When asked whether you want to save, click Yes
  10. Update the following records:
     
    Property # Finished Basement
    524880 1
    688364 8
    611464 4004
    749562 995
    427115 -10000
    200417 0
    927474 505
    682630 -1750
    288540 0
  11. Close the table
  12. In the Navigation Pane, right-click the Properties form and click Design View
  13. In the Controls section of the Ribbon, click the Check Box control Check Box and click and unoccupied area of the form
  14. Click the label next to it and, in the Property Sheet, click the All tab
  15. Change the following properties:
    Name: lblFinishedBasement
    Caption: Finished Basement

Characteristics of Check Boxes

If a check box will receive its value from a table, the corresponding column must use a number-based data type. A check box is used to express a Yes/No value (also called a Boolean value) as true or false. If the value of the record is 0, the check box is unchecked. For any other value, the control is checked.

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).

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.

Practical Learning: Using Check Boxes

  1. In the form, click the check box next to Finished Basement to select it
  2. In the All tab of the Property Sheet, change the following properties:
    Name: FinishedBasement
    Control Source: FinishedBasement
  3. Move the label to the left of the check box and position both below the other controls

    Altair Realtors - Properties

  4. Close the form
  5. When asked whether you want to save the changes of the form, click Yes

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, 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.

Practical Learning: Ending the Lesson

  • Close Microsoft Access
 
 
   
 

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