![]() |
Properties of Database Fields |
We have seen so far that, in order to use anything in your database, you must first create it, but the process of creating something depends on its type. For example, tables are created in Datasheet View or designed in Design View. Queries are created by adding fields from existing tables or other queries. Forms and reports are created by adding existing fields or adding independent fields to them. Fields are created and added to these objects. When you start a brand new table in Datasheet View, Microsoft Access assigns various names to its fields (or columns). These are Field1, Field2, etc. We saw how to change these fields. If you start a brand new table in Design View, you must specify a Field Name for each column that will be used.
When you create a simple query, as you select fields from a table or query and add them to the new query, they keep their names and, in this case, the names are held in the originating object (the original table or query). You can still create new fields by combining existing fields from the original table or query. When you create such a new field, you must give it a name. To create a new field in a query, you can select an empty column and, in the field box, assign an expression to it. After doing this, the query would provide a suggested name like Expr1. You can then change the name to something else than Expr1.
|
|
|
Record and Control Source |
|
We had previously mentioned that there are fields created from tables and used on the objects, and that these objects also use fields that either existed already or fields that are independent of any other. When adding or creating a field on a form or report, if data for that field originates from a previously created column on a table, the field is said to be “bound” because its data is bound to an existing field. If a field is either created as an expression that combines other fields or if the field doesn't depend on any existing field, the field is said to be unbound. |
|
|
|
|
Visibility |
|
After adding a field to a form or report, it becomes visible and can be used. An object is referred to as visible if it can visually be located on the screen. A user can use an object only if he can see it. Most of the time, you will not be concerned with this aspect. On the other hand, there are situations that will lead you to create a control but hide it from the user. For example, since you cannot declare a (VBA) variable in Microsoft Access, you can instead create a control such as a text box, make it hold a value that you can use in an expression but hide it from the user who would never need to use such an object. |
|
Availability |
|
In order to use a control on a form or a report, the object that is hosting the control must allow it. For example, the user cannot type text or change the value of a combo box if this action was not made possible. This aspect is controlled in two different ways. |
|
|
|
|
Field Locking |
|
During data entry, a user usually clicks a field to give it focus and starts typing. As we will learn, some fields get an automatic number set and controlled by Microsoft Access. Some other fields use data created from an
expression. These types of fields do not support data entry and their content cannot be changed directly by the user. In some other circumstances, you will create fields but would not like the user to be able to change their value. For this reason, you can lock
such a field. |
|
|
|
|
Tool tip |
|
A tool tip is a small yellow border-less box that appears when the mouse is positioned on top of a control for a few seconds. It is a fast means of providing help to the user. Because only the form displays controls in a manner suitable for them, a field can display a tool tip only on a form. |
|
|
|
|
Status Bar Text |
|
When a field receives focus, you can display a sentence on the status bar to provide some guidance or suggestion to the user. The text that displays on the status bar should be explicit enough but not too long. When creating it, make sure it can fit in the left section of the status bar, which should be long enough to explain anything. |
|
|
|
Database Objects Captions |
|
A caption is text that guides the user to identify a window or another object. As it is the most important property of a label, it may appear as a significant guide to the user. For a table, a query, a form, or a report, the caption is text that displays on the title bar. For a label, the caption is text the user can read on the control. After creating an object such as a table, a query, a form, or a report, Microsoft Access uses its name as its caption.
The caption of a query depends on the type of query. If you create the types of queries we have used so far, which consisted of selecting fields, these are called Select Queries. The title bar of such a query would use the same technique as the table but the category of object would be Select Query:
If you create a form using the Form Wizard or if you create a report using the Report Wizard, Microsoft Access would use the name you provided as its caption. If you design a brand new form or report by adding fields to it, it would have a caption as Form1 or Report1 followed by the object category as the Form or the Report. To display its caption, Microsoft Access would use the same convention as seen above:
If you create a report or a form using a wizard, after you have saved the object, its name would be used as its caption:
|
|
Controls Captions |
|
So far, we have used two techniques to create fields on a table: using the Datasheet View or using the Design View. In Datasheet View, the name you give to a column also becomes its caption. This is one of the limitations of the
Datasheet View. Most programming or development environments, including Microsoft Access, separate the name of a field from its caption. The name is used by you and the operating system to identify an object. The caption is most used to guide the user. To help with this, the Design View of a table allows you to make a distinction on these two aspects of a field.
The caption would display as follows:
Although this works, you should set a (short) caption that indicates what the field is used for. For this example, an appropriate caption could be
Empl # or Employee # or Empl. Nbr.
When you run the query, it would display the caption you had set:
To set or change the caption of a form, a report, or a label, access its Properties window. Then, click the Caption field and edit or replace it as necessary. If you delete the Caption of a form or a report, Microsoft Access would use the
ObjectName: Category formula to create its caption. |
|
|
|
|
Text Alignment |
|
Most fields or controls of a database display text. This includes labels, text boxes, and combo boxes, etc. To enhance the appearance of the fields or controls, you can specify the alignment of text of a control. This property has three values: left, center, or right. By default, the alignment of text-based fields, including any caption on a label, is set to the left (following US English). The alignment of fields that display numbers or dates is set to the right. If you don't like these suggestions or for any other reason, you can change the text alignment of a field or control.
There are various ways you can change text alignment. After selecting it and while in Design View, the Formatting toolbar provides the
Align Left |
|
|
|
|
Font |
|
A font is an art effect made of designed symbols used to represent letters and other characters on a field, a control or a label. A font is designed by an artist but usually follows a specific pattern. For example a font designed to produce symbols readable in the US English language must be designed by a set of predetermined and agreed upon symbols. These symbols are grouped in an entity called the English alphabet. When designing such a font, the symbols created must conform to that language.
Because a font is primarily an art, one font can be significantly different from another and a font is not necessarily a series of readable symbols. The names of fonts installed on your computer can be seen in the Fonts window accessible from Control Panel. Here is an example (from a Windows 98 installation): |
![]() |
|
By default, Microsoft Access uses a font called Arial to display columns and fields on tables, queries, and reports. The default font used on forms is called Tahoma. If you want to use a different font to display text on labels and fields of your database, you can changes these defaults. To set or apply a font on a label or a field, after selecting it in Design View, you can use the Formatting toolbar which is equipped with the Font combo box. You can click its arrow and select a font from the list. Alternatively, to change a font, access the Font Name property of a label or a field in the Properties window, click the arrow of the property’s combo box and select from the list. When changing the default font, in other words, if you decide to change the default font, you should use only the most popular fonts that are more likely to be found on your user’s computers. To set or apply a font on a group of labels and/or fields, select the group and either use the Formatting toolbar or, from the Properties window, click the Font Name combo box and select from the list. Besides its name, a font is also known for its size. The size defines how much height and proportional width would be used to represent the characters of the selected font. To change or set the size of the font used to display the characters of a label or a field, after clicking it or selecting the group of controls, on the Formatting toolbar, you can click the arrow of the Font Size combo box and select a size from the list. You can also click the label or field, access its Properties window and select a size from the Font Size combo box. In both cases, if you want a size that is not in the list of the Font Size combo box, you can simply type the desired natural number and press Enter or Tab. As done for the font names, you can also select a group of labels and/or fields and apply the same size to them. A font is also characterized by its style. The style controls how the font displays, in normal, bold, italicized, underlined, some of these characteristics or all of them. Here are examples of these characteristics:
To change or set the font style of a label or a field, after selecting it and while in Design View, on the Formatting toolbar, click the
Bold |
|
|
|
|
Fore Color |
|
The color is a non-spatial characteristic applied on a Windows control or a field to
define its visual density of darkness or clarity. This density itself is a numeric value created by combining three numbers that each ranges from 0 to 255 included. The first number is also referred to as red. The second is referred to as green. The third is referred to as blue. A combination of red, green, and blue creates a color. Since each number has 256 values, if you multiply them as 256 * 256 * 256, you get 16777216. This means that
various combinations of red, green, and blue produce more
than 16 million possible colors.
After clicking a color, it becomes selected on top of the button. The next time, if you need the same color, you can just click the Font/Fore Color button and the already selected color would be applied. If, during design, you will keep changing colors, you can permanently display the Font/Fore Color as a window on your screen. To do this, click the arrow of the Font/Fore Color button and drag its short title bar:
This would create a window based on it. |
| Black | Brown | Olive Green | Dark Green | Dark Teal | Dark Blue | Indigo | Gray- 80% |
| Dark Red | Orange | Dark Yellow | Green | Teal | Blue | Blue-Gray | Gray-50% |
| Red | Light Orange | Lime | Sea Green | Aqua | Light Blue | Violet | Gray-40% |
| Pink | Gold | Yellow | Bright Green | Turquoise | Sky Blue | Plum | Gray-25% |
| Rose | Tan | Light Yellow | Light Green | Light Turquoise | Pale Blue | Lavender | White |
| Names of Preset Colors |
|
Besides the Font/Fore Color button on the Formatting toolbar, to set the font color of a field or label, while in Design View, you can right-click it, position the mouse on
Font/Fore Color and click one of the preset colors. Once again, you can use only one of the existing colors.
This displays a constant list of colors. If none of the available colors is appropriate for the task at hand, you can click the Define Custom Colors >> button to expand the dialog box:
The expanded Color dialog box allows you to either select one of the preset colors or to custom create a color by specifying its red, green, and blue values. You can change the color in four different areas:
After selecting or specifying a color, you can click OK or press Enter. |
|
|
|
|
Background Color |
|
You can enhance the appearance of an object by change its background color. This
aspect can be applied only to the object that is selected. Based on this, you can paint the background of one section of a form or a report without changing the other sections. In the same way, you can paint the bounding rectangle of a field or a label independent of the other fields or labels. If you do not want a label or field to be painted with a particular color, you can make it transparent by setting its Fill/Back Color property to Transparent. Using the Properties window, you can also make a control such as a text box transparent by using the Back Style property. Its default value is Normal. To be able to see through the control, you can set this property to Transparent. |
|
|
|
|
Special Effects |
|
Microsoft Access provides some special visual effects used to raise or sink, etc a section of a form or report, a label or a field. These effects can be controlled by using the Special Effect button on the Formatting toolbar, by right-clicking a label, a field or a group of labels and/or fields, positioning the mouse on Special Effect, and clicking from the list. You can also access the effects from the Special Effect property of the Properties window. The special effects appear as follows: |
![]() |
|
|
|
|
Borders |
|
A border is a line that defines the limit of an object. You can control how the border of a label or a field
is drawn. The borders of a label or field can be drawn with a variant width of a line.
The Border Style characteristic can be used in combination with the Special Effect property. Some of these effects depend on the
Special Effect value and may not appear as expected. |
|
Location |
|
When you add or drag a control to a section of a form or report, it assumes a distance from the left border of the section and from the lower border of the bar of that section. These two dimensions are referred to as its location. The location of an object is determined by its Top and its Left properties:
The location of an object can be set by dragging its top-left handle |
|
|
|
|
Dimensions |
|
The width of an object is the distance from its left border to its right border. The height of an object is the distance from its top border to its bottom border. The width and the height of an object are referred to as its dimensions. The width of a form or report is the common width of each one of its sections. All sections use the same width. The height of a form or report is the total height of all of its sections. For this reason, the form and the report do not have a height because they let each section control this characteristic.
The dimensions of an object can be set by dragging one of its middle handles |
|
|
|
|
Tab Ordering |
|
When performing data entry, we saw that the user can press Enter or Tab to navigate from one field to another. Because a label cannot receive focus, it is not affected by this navigation. The controls that participate in this navigation are part of a group. Participation to this group is controlled by the
Tab Stop Boolean property. In order for a control to receive focus when the user presses Tab, the control must have its
Tab Stop property set to true. When you add a Windows control to a form, it is directly made part of that group because its
Tab Stop property is set to Yes. If you want to remove a control from this group, you can set its Tab Stop property to
No. Of course, an alternative is to set its Enabled property to
No. |
|
AutoFormat |
|
Microsoft Access Design Templates |
|
We saw that, when you create a database using the Database Wizard, you have the option of applying one of the designs provided by Microsoft Access and you can apply it to your forms and reports. In the same way, if you create a form using the Form wizard, as we have done in previous lessons, you can select one of the designs and apply it to the form. This concept also applies to reports. If you create a form or report in Design View, you would have only the Standard design. You can still apply one of the designs supplied by Microsoft Access. To do that, open the form or report in Design View. Then, on the main menu, click Format -> AutoFormat... The AutoFormat would appear and allow you to select any of the available designs. After selecting a design, you can click OK |
|
Creating a Form Template |
|
If you design a good looking form or a report and want to use its design in other databases, you can add it to the list of designs of the AutoFormat dialog box. To do that, open the form or report in Design View, then, on the main menu, click Format -> AutoFormat... On the AutoFormat dialog box, click Customize. The Customize AutoFormat dialog box allows you to modify or delete one of the existing designs, or create a new one. |
![]() |
|
|
|
|
MOUS Topics |
| S22 | Switch between object views |
| S37 | Move and resize a control |
| S38 | Modify Format Properties (font, style, font size, color, caption, etc.) |
| S39 | Use the Control Toolbox to add controls |
|
Exercises |
|
Yugo National Bank |
|
|
Tenley Associates |
|
|
Watts A Loan |
|
|
|
||
| Previous | Copyright © 2002-2005 FunctionX, Inc. | Next |
|
|
||