|
|
Probably the most important and the most obvious characteristic of a label is the text it is displaying. The text is the label's Caption. If you click the Label on the Toolbox and click on the form, you must first define its caption. If a label already has a caption, there are various ways you can edit it. For example, use the same techniques we reviewed for editing text-based properties. On the other hand, to edit the caption of a label, on the form, click inside the label. That would put it into edit mode and you can edit it as you wish.
The appearance of a label is visibly controlled by its font characteristics. The Font name, also called its face, is the name of the font as defined by the operating system. We saw that there are various ways you can define the font characteristics of a control like the label. The Formatting toolbar is equipped with appropriate combo boxes and buttons. These characteristics can also be modified using their corresponding properties from the Properties window.
The dimensions of a label control its Width and Height. Although the dimensions are closely related to the font characteristics, they can be independently defined. There are two main ways you can resize a label, which is equivalent to changing its dimensions. To set your own dimensions, in the Format tab of the Properties window of the label, change the values of the Width and Height properties. Unless you plan to show the background color of a label, probably the best way to resize a label is to make it adjust to the dimensions depending on the font size and the total characters width. To do this, position the mouse on one of the label's handle and double-click. The label's width and height would be set to accommodate its caption.
The position of a label is controlled by its Top and Left properties. The Top property defines the measure from the top left corner of the section where the label is positioned, to the top left corner of the label itself. There are two main ways you can set the position of a label. On the Properties window, you can change the values of the Top and Left properties. On the other hand, you can place your mouse on the top left corner of the label until the mouse pointer turns into a pointing finger. Then click and drag in the desired direction.
|
|
Practical Learning: Designing Labels
|
|
- Open the Video Collection1 database
- From the Forms section of the Database window, right-click the Videos1 form and click Design View
- From the Toolbox, click Label
and click in the top left section under the Header bar.
- Type Video Collection – Video Details and press Enter
- While the new label is still selected, on the Formatting toolbar, click the arrow of the
Font combo box and select Garamond
- Click the arrow of the Font Size combo box and select 20
- Click the Bold button

- Click the arrow of the Font/Fore Color button and click Yellow (column 3 - row 4).
- To resize the label, position the mouse on one of the handles surrounding the label and
double-click
- To reposition the label, on the Format property page of the Properties window, click Left, type 0.25 and press
Enter
- Change the value of the Top property to 0.040
- While the label is still selected, on the Properties window, click the Other tab
- Click Name, type lblMainTitle and press Enter
- Click anywhere on the form (to deselect the label)
- Right-click the Video Collection label and click Copy
- Right-click anywhere in the same Form Header section and click Paste
- While the new label is still selected, on the Properties window, click the All tab
- Click Name and type lblShadowTitle
- Click Left and type 0.29
- Click Top and type 0.075 and press Enter
- On the Formatting toolbar, click the arrow of Font/Fore Color and click Dark Red (1st column - 2nd row).
- On the Object combo box of the Formatting toolbar, select lblMainTitle and notice that it is selected on the form
- On the main menu, click Format -> Bring To Front
- Drag the top border of the Detail bar up completely to shrink the Form Header section until you cannot drag up anymore
- Before leaving, in the Form Header section, draw a fake line that touches both labels to select them. Then press Ctrl + C to copy
- To preview the form, on the Form View toolbar, click the View button
- On the menu bar, click Window -> Size To Fit Form:
- Close the form. When asked to save the form, click Yes.
- On the Database Window, right-click the Actors1 form and click Design View
- Right-click the area under the Form Header bar and click Paste
- While both labels are still selected, in the Properties window, click the Format tab. Change or edit the value of Caption to display Video Collection – Actors/Actresses and press Enter
- Double-click one of the handles of the labels to resize them
- Preview, save and close the form
|
|
Text-Based Controls: The Text Box |
|
|
A text box is a Windows control used to get or display text for the user’s interaction. At its most regular use, a text box serves as a place to fill out and provide information. You can also use it only to display a text without allowing the user to change its content.
Like most other controls, the role of an edit box is not obvious at first glance; that is why it should be accompanied by a label that defines its purpose. From the user’s standpoint, a text box is named after the label closer to it. Such a label is usually on the left or the top side of the corresponding edit box.
There are two main ways you can add a text box to a form:
- From the Toolbox, you can click the Text Box control and click on a section of the form. Unless you have a good alternate reason, most of your text boxes will be placed in the Detail section. Some text boxes used in expressions can be placed in another section. By default, placing a text box on the form also adds a corresponding label to its left.
- If you drag a text-based field from the Field List and drop it on the form, the field would place a text box and its corresponding label.
|
|
Like every control on a form, the dimensions of the text box are controlled by its Width and Height properties. The position of a text box is controlled by its Top and Left properties.
To make a text box read-only, that is, if you don't want the user to enter text in an edit box, there are various alternatives. If you change the Enabled property from Yes to No, the text box would have a gray background and cannot receive focus. If you set the Locked property from No to Yes, the control would appear with a normal (white) background.
The Special Effects of the text box are expanded as compared to those available on a label. Besides the ability to raise or sink a text box, you can give it a thick, etched, or shadow border.
After adding a text box on a form, you can configure it to receive its data from an existing table. This can be done after the Record Source of a form has been defined. To link a text box to the object that is the Record Source of a form, click the arrow of its Record Source combo box and select the desired field.
|
|
Practical Learning: Designing Text Boxes
|
|
- In the Forms section of the Database window, right-click the Actors form and click Design View
- On the form, click the Actor text box
- On the Formatting toolbar, click the arrow of the Special Effect button and click
Special Effect: Shadowed
- Preview, save and close the form
|
|
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 or a dialog box 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 or a dialog box. To use a button, the user position his mouse pointer 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 or dialog box is displaying. A caption like Cancel is usually accompanied by another OK button on the form. 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 Command Button control on the Toolbox and click on the desired section of the form. On the Toolbox, if the Control Wizard button was down or clicked, 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 Toolbox, you can click the Control Wizards button to have it up.
|
|
Practical Learning: Creating Command Buttons
|
|
- Open the Bethesda Car Rental1 database
- From the Forms section of the Database window, double-click the About1 dialog box to open it
- After viewing the dialog box, switch it to Design View
- On the Toolbox, after making sure that the Control Wizard button is down , click the Command Button control and click the empty area in the Form Footer section on the right side of the warning label
- On the first page of the Command Button Wizard, in the Categories list, click Form Operations
- In the Actions list, click Close Form
- Click Next
- On the second page, replace the content of the Text edit box with OK (and make sure the Text radio button has been selected) and click Next
- Change the name of the button to cmdOK and click Finish
- Resize the button as you see fit
- Preview the dialog box:
- Save the form. To close it, click OK
|
|
Characteristics of Command Buttons
|
|
|
Like all other “visual” controls, a command button has a Name property, a location (Left and Top), and dimensions (Width and Height). Because of their anticipated behavior, command buttons are the most commonly used object to initiate an action. As such, they are used to open other forms, reports of the same database, or simply to display a message box.
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 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.
|
|
Practical Learning: Configuring Command Buttons
|
|
- The Bethesda Car Rental1 database should still be opened.
From the Forms section of the Database window, right-click the About1 dialog box and click Design View
- On the form, click the OK button to select it. In the Properties window, click the Other tab and double-click Default to change its value from No to Yes
- Save and preview the dialog box
- To close, press Enter
|
|
Introduction to 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). This is done the same way we did with the table: using the Lookup Wizard.
|
|
Practical Learning: Creating a Combo Box
|
|
- Open Video Collection1 database and open the Videos2 form
- After previewing it, to switch it to Design View, on the Form View toolbar, click the View button
- On the toolbox, make sure the Control Wizard button is clicked
- On the Toolbox, click the Combo Box button
- On the form, click between the Title and the © Year text boxes:
- On the Combo Box Wizard dialog box, make sure the first radio button is selected and click Next
- In the list of tables, click Directors and click Next
- From the Availability Fields list, double-click Director and click Next
- Make sure the Hide Key Column check box is checked and click Next
- Click the arrow of the combo box and select DirectorID
- Click Next
- For the label of the combo box, type Director to replace the suggested label and click Finish
- Save the form and switch it to Form to preview it
- After viewing the form, switch it back to Design View
|
|
Introduction to 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 her 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.
|
|
Practical Learning: Creating a List Box
|
|
- The Video Collection1 database should still be opened with the Videos1 form in Design View.
On the Toolbox, make sure the Control Wizard button is clicked
- On the Toolbox, click the List Box button
- On the form, click on the right side of the DirectorID combo box
- On the first page of the List Box Wizard, click the second radio button and click Next
- Click the empty field under Col1 and type G
- Press Tab and type PG
- Complete the list with the following options: PG-13, R, NC-17, X, and N/R
- Click Next
- Click the arrow of the combo box and select Rating
- Click Next
- For the label, type Rating and press Enter
- Save, preview, and close the form
|
|
Properties of Combo and List Boxes
|
|
|
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 the primary key of the parent table that holds the actual data to display, and the selected foreign key that exists on the table that host the foreign key. After creating the combo box, especially if you used to 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 you, 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.
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
|
|
- Open the Bethesda Car Rental1 database
- In the Forms section of the Database window, double-click the RentalRates form to open it.
If you do not have it, open the RentalRates1 form
- After viewing the form, switch it to Design View
- On the Toolbox, make sure the Control Wizard button is down
To create a list box, on the Toolbox, click the List Box button and, on the form, cl under Detail on the top-left section
- On the first page of the List Box Wizard, make sure the first radio button is selected and click Next
- In the list of tables, click Car Categories and click Next
- In the Available Fields list, click the select all button and click Next
- Make sure the Hide Key Column check box is checked and click Next
- Change the label to Rental Rate by Category and click Finish
- Preview the form in Form View and switch it back to Design View
- On the form, click the list box to select it
- On the Properties window, click the All tab. Click Name. Type lstRentalRates and press Enter
- Set the Column Heads property to Yes
- Change the Column Widths as follows: 0”;0.875”;0.85”;0.85”;0.85”;0.85”
- Resize the list box control and the form appropriately
- Save and preview the form
- Close the form
|
|
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 his or her 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
|
|
- Open the Danilo Pizza1 database
- From the Forms section of the Database window, double-click the CustomersOrders form to open it
- After viewing the form, switch it to Design View
- On the Toolbox, make sure that the Control Wizards button is down .
Click the Option Group control
- On the form, click under the Processed By label
- On the first page of the option Group Wizard dialog box, click the empty box under Label Names and type Small
- Press the down arrow key and type Medium
- Press the down arrow key, type Large
- Click Next
- To set the default choice, click the arrow of the combo box and select Medium
- Click Next
- Accept the values suggested for the option buttons and click Next
- Click the arrow of the combo box and select PizzaSizeID because the option button selected will be held by, or carried by, or stored in, the PizzaSizeID foreign key
- Click Next
- Accept to have the Options Buttons with an Etched border. Click Next
- 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, 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 pointing finger arrow 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
|
|
- The Danilo Pizza database should still be opened with the CustomersOrders form in Design View.
On the form, click an unoccupied area to make sure nothing is selected. 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
- In the Properties window, click the All tab and click Name. Type fraPizzaSize and press Enter
- Enlarge the border of the option group to include the text boxes that correspond to the option buttons
- Save and preview the form
- Switch it back to Design View
|
|
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 his or her decision by clicking in the square, which toggles a check mark R. Toggling means, that if the square box were empty £, after clicking it, a check mark would appear in it R:
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 can behave independently with regards to the other check boxes of the same group. Therefore you can create check boxes anywhere on the form. 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.
|
|
Practical Learning: Adding a Check Box
|
|
- The Danilo Pizza database should still be opened with the CustomersOrders form in Design View.
On the Toolbox, click the Check Box control and click the group box under the Toppings label
- While the new check box is still selected, in the Properties window, click the All tab and click Name. Type txtPepperoni and press Enter
- In the Control Source, select Pepperoni
- On the form, click the label of the new check box. Click it again and edit its string to display Pepperoni
- From the Field List, drag Sausage and drop it in the group box under the Toppings label
- In the same way, drag the ExtraCheese, the Onions, and the Olives fields to the same group box
- Using the techniques of control resizing and moving, complete the design of the controls
- Save and preview the form
- Close the form
|
|
A toggle button is a type of button that behaves like a check box. The first difference is that it displays like a command button but behaves like a check box. The second difference is that, 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 on the Toolbox 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.
|
| S17 |
Use the Control Toolbox to add controls |
| S18 |
Modify Format Properties (font, style, font size, color, caption, etc.) of controls |
- Open the Yugo National Bank database
Open the Customers table in Design View. Insert a new field just under
CustomerID. Name it Created By and set its Data Type to Lookup Wizard.
In the Lookup Wizard, select the LastName and Title fields from the
Employees table. Keep the label as Created By and delete 0
as the Default Value. Save and close the table
- Open the Customers form in Design View and delete the AccountTypeID
text box.
Use the Combo Box Wizard to create a field for the AccountTypeID column.
Include the AccountType field from the AccountTypes
table. Store its values in the AccountTypeID field and set
its label to Account Type. Change the Name of the combo box to cboAccountType
Re-adjust the Tab Order then design the form as follows and save it before
closing it:

- Open the Customers table in Design View. To make sure that only
employees who are allowed to, can actually create new accounts, in the
Lookup section of the EmployeeID field, open the SQL statement.
Add the CanCreateNewAccount field and set its Criteria to be True but
don't show it to the user

Save and close the table
- Create and design a form based on the Transactions table. Save it
as Transactions

Close the form
- Open the Transactions form and perform a
few transactions then close it
- Using the Command Button Wizard, create a button used to close the
form on each form of the database. Set the caption of the button as Close
and name it cmdClose
- Open the Watts A Loan database.
Design a form based on the LoanProcessing table
Use the Combo Box Wizard to create a field for the EmployeeID column.
Include the LastName and the Title fields of the Employees table. Make
sure its values are stored in the EmployeeID field and set its label
to Processed By. Change the Name of the combo box to cboEmployee.
Use the Combo Box Wizard to create a field for the CustomerID column.
Include the AccountNumber and the LastName fields from the Customers
table. Make sure its values are stored in the CustomerID field and set
its label to Account Number By. Change the Name of the combo box to
cboCustomer
Use the Combo Box Wizard to create a field for the TypeOfLoanID
column. Include the TypeOfLoan field from the TypesOfLoan table. Make
sure its values are stored in the TypeOfLoanID field and set its label
to Type of Loan. Change the Name of the combo box to cboTypeOfLoan
Using the items from the Field List, complete the design of the form
as follows:

Save and close the form
- Create a title with a shadow label in the Form Header section of
each form as follows:
- Using the Command Button Wizard, create a button used to close the
form on each form of the database. Set the caption of the button as Close
and name it cmdClose
|
|