Home

The Characteristics of a Table

 

Properties Fundamentals

Introduction

In our introductions to Windows controls, we learned how to position some objects on a form or a report and how to specify their sizes. These two aspects, the location and the size, are referred to as characteristics of an object. In computer programming or in application development, a property is a piece of information that describes an object.

Therefore, a property can be the location (position) of an object, its size, its color, its text, or anything that characterizes it. Some properties of an object are visible and can be set by you the database developer. Some properties can be set or changed by the user when interacting with the computer (but you should be able to predict or control what the user can or should do). Some other properties can be changed by either you or the user.

As seen in the previous lessons, there are various ways you can change the properties of a control but the table, the form, or the report must be displaying in Design View. The properties of an object can be accessed from the Properties window. The table on one hand has a different way of dealing with properties than the form or report on the other hand.

Practical Learning: Introducing Properties

  1. Start Microsoft Access
  2. To create a new database, click the Office button and click Blank Database
  3. Set the name of the database to Hotel Management1 and click Create
  4. To save the default table, right-click the Table1 tab and click Save
  5. Set the name to Employees1 and press Enter

Types of Properties

In order to change a property, first open the table, the form, or the report in Design View, click the object whose property you want to change. In the Properties window, locate the property you want to change and click it. Each field in the Properties window is divided in two sections: its name and its value:

The left column of the a tab in the Properties window displays the name of a property. Although you can click it to select it, you cannot change it. The property name can be made of one word such as Width. It can also be made of a combination of words, such as Border Style. Regardless, in our lessons, each property will be called by what displays on that left column. This means that, if a property displays "Width", we will call it "The Width Property". If it displays "Allow PivotTable View", we will call it "The Allow PivotTable View Property".

The right column of a tab of the Properties window displays the name of the property. This is referred to as the value of the property.

String Properties: Some values of properties can be made of one or more characters or words. Here is an example:

To change the value of a string property:

Numeric Properties: A property is called numeric if it must hold an integral or decimal value. An integer is a natural number that does not take a decimal portion. Such a number can be made of digits only. For such a field, make sure you provide an integer of appropriate range, as you will be directed to do. A decimal number, also called a floating-point number, can be made of digits or a combination of digits and one period (or the symbol used as the decimal separator in your language; you can find this out in the Regional Settings of the Control Panel) in between. When setting such a value, make sure that either you type only digits, or you type digits and one decimal separator. The decimal separator can be anywhere in the value, Microsoft Access would take care of formatting it if it judges it necessary.

To change the value of a numeric property:

Some numeric properties, such as the color properties, allow you to either type a number (provided you know what number you want to use) or to use an intermediary approach (namely a dialog box) to select an appropriate value.

Expressions Properties: Some properties are made of a combination of specific characters and digits. Examples are the format of a date or time, the concatenation of strings to produce another string. To specify the expression, you can use the same approach we described for a string. After entering the expression, Microsoft Access would analyze it. If you respect the rules of the type of expression you are supposed to create, it would be used. If you enter a wrong expression or Microsoft Access cannot identify what the expression would produce, you may get either an error or an unpredictable result.

Boolean Properties: A property is referred to as Boolean if it can have only either a Yes or a No value, an On or an Off value, a 0 or no 0 value. Both values of the property are stored in a combo box. To change the value of Boolean property:

Enumerated Properties: Some properties provide a list of options as the possible values of the property. The list, which cannot be changed, comes as a combo box from where you can select one item. To change the value of an enumerated property:

The Design View of a Table

 

Introduction

When we studied the creation of tables in Lesson 2, we saw how to create columns in the Datasheet View. Like the form or the report, the table can be presented in Design View. In fact, as you will see from now on, that's the best place to create the columns of a table. Instead of the Datasheet View, you can start a new table in Design View or you can modify an existing table in the Design View:

Mostly you, the database developer, have access to the Design View of a table. The user will hardly, if ever, use that view.

Practical Learning: Introducing the Table's Design View

A Table in Design View

A table in Design View is divided in two sections: one in the upper area and another in the bottom:

The top area is made of columns and rows. The columns are named Field Name, Data Type, and Description. When necessary, you will be directed to type or select something in one of the cells; the name of the column under which you must type or select will be specified in the lessons.

The lower portion of the window is made of two sections. The left section is made of two tabs labeled General and Lookup. Each tab contains two columns and various rows. The number of rows and the contents of cells depend on what is selected in the upper section. In our instructions, you will be directed when to do something in a tab or in a cell. As mentioned for the Properties window, the left column of the tabs in the lower section lists the names of characteristics. You cannot change the name of a property. The right column contains the values of the characteristics. When prompted to so so, you will create a new value, modify an existing value, or select one from a combo box. In some cases, a wizard will assist you with creating an expression as the value of a property.

The right side of the bottom section of the table is made of a read-only area that describes what is selected in one of the tabs of the lower-left section.

When given an instruction, you will be dealing with items in the top or the bottom section. To work on an item, sometimes you will be asked to click it to give it focus. You can then click the desired item. Another technique you can use to move from one section to the other is to press F6.

Introduction To Tables Columns Design

 

The Name of a Field

In Lessons 2 and 3, we had various introductions on how to create tables, forms, and reports. We also learned how to name them. We learned how to populate tables with columns and how to add fields to forms or reports with Windows controls but we did not go into their details as they relate to the operation system. One of the rules to observe in application or database development is that every object must have a name.

In our introduction to tables, we saw how to create a column in the Datasheet View. In the Design View:

Practical Learning: Creating Table’s Columns in Design New

  1. Under the Field Name column header, double-click ID and change it to EmployeeID
  2. Click the empty box under EmployeeID, type DateHired
  3. Press the down arrow key and type EmployeeNumber
  4. Complete the columns as follows:
     
    EmployeeID
    DateHired
    EmployeeNumber
    FirstName
    MiddleInitial
    LastName
    MaritalStatus
  5. To save the table, press Ctrl + S

The Visibility of a Column

An object such as a column is referred to as visible if it can visually be located on the screen. A user can use a column only if it is visible. When reviewing tables, we saw that, to hide a column, you could right-click it and click Hide Column. To hide a group of columns, you can right-click any column and click Unhide Column... Then, in the Unhide Column dialog box, clear the check box of any column you want to hide.

If you hide a column and save the table, the column is still available although it is not visible at a particular time. Also, if you hide a column, it has no influence on the form or report that is based on the table. This means that a column can be hidden from a table but its corresponding control on a form or report would still show it. In fact, if you display the Field List of a form or report that has the Record Source specified, all of the columns of the table would display in the Field List, even if they are hidden on the table.

Text on the Status Bar

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.

The process of creating a status bar text depends on the control. To create a status bar text for a field when designing a table, in the Description section for the field, type the string you want. Such a string would appear when the field receives focus in the table in Datasheet View. If the field participates in an expression for a field of a query, the status bar text would not appear.

To create a status bar text for a field on a form, while in Design View, access the Status Bar Text property of the control and type the desired string. Only the controls that can receive focus have a Status Bar Text property. For the same reason, because no field can receive focus on a report, this property is not available for fields on a report.

Practical Learning: Setting Status Bar Text for Fields

  1. In the top section of the table, click EmployeeID and press Tab twice
  2. In the Description field for the EmployeeID field, type
    Automatic number generated by the database engine
  3. Press the down arrow key. That puts the caret in the Description field for the DateHired field. Type
    Date the employee was officially hired
  4. In the left section, click MiddleInitial, click the box under the Description column that corresponds to MiddleInitial, and type Middle initial made of one letter
  5. Press Ctrl + S to save the table
  6. To switch the table to Datasheet View, right-click its tab and click Datasheet View

The Caption of a Field

When we studied tables creation, we saw how to create columns and we saw how to set the string on the header portion of a column. Here is an example of a column that displays Order Date on its header:

On a column of a table, a caption is the string that the user sees on the column header. In this example, the caption of the column is Order Date. The caption that a column displays is not necessarily the name of the column.

If you create a column of a table in the Datasheet View, the string you specify for the column will represent both its name and its caption. In some cases, you will need or want to display a multi-word string as the caption of a column. This is because the caption should be as explicit and simple as possible. For example, it is better for the user to read Date of Birth than DateOfBirth, or Full Name instead of FullName.

We already saw how to specify the name of a field in the Design View of a table:

Practical Learning: Setting Objects Captions

  1. Notice the words in the columns headers (the captions)
     
  2. Enter the following records:
     
    DateHired EmployeeNumber FirstName MiddleInitial LastName MaritalStatus
    08/12/2005 297-497 Arlene P Bonds Married
    10/25/2006 406-153 Jeremy H Kaminski  
    05/06/2006 927-597 Thomas   Jacobson Single
    07/10/2006 759-027 Christie A Aronson Married
    07/10/2006 394-759 Carlton   Huge Divorced
    02/22/2007 927-406 Patricia D Thorn Single
    03/02/2007 294-759 Justine S Garland  
  3. To switch the table to Design View, in the Navigation Pane, right-click Employees1: Table and click Design View
  4. In the top section of the table, click EmployeeID
  5. In the lower section of the view, click Caption
  6. Type Empl ID and press Enter
  7. In the same way, set the captions of the following fields:
     
    Field Name Caption
    EmployeeNumber Empl #
    MiddleInitial MI
  8. To save the table, press Ctrl + S
  9. To switch the table to Datasheet View to see the result, right-click the Employees1 tab and click Datasheet View
     
    Employees: Captions

The Font on the Fields of a Table

 

Introduction

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 English 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 different from another and a font is not necessarily a series of readable symbols.

Just like everything else in the computer, a font must have a name. A font is also designed to assume different sizes. Before using it on a data field or label, the font must have been installed. Microsoft Windows installs many fonts during setup.

The font used on the Microsoft Access application to display its menu and the names of objects is controlled by the operating system. Unless you have a good reason, you should not be concerned with it.

The names of fonts installed on your computer can be seen in the Fonts window accessible from Control Panel. Here is an example:

Fonts of a computer

Microsoft Access uses some default fonts to display columns and fields on tables, forms, and reports. If you want to use a different font to display text on labels and fields of your database, you can changes these defaults. 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.

The Fonts of Columns of a Table

Most of the time, you will not need to let your users access your tables. Still, if you do, you can make it friendlier with colors and fonts. When designing a table, Microsoft Office Access 2007 applies a default font (named Calibri) to the headers of the columns. If you want, you can change it. To assist you with setting the fonts of columns, the ribbon is equipped with a Font section in the Home tab.

To change the font of columns and records of a table, display the table in Datasheet View. On the ribbon, click Home. In the Font section, click the Font combo box and select the desired font. The font you select will be applied to all columns and all values (the records) of the table. The font you apply to a table does not have any influence on the form(s) or report(s) that are, or will be, based on that table.

Practical Learning: Setting the Font of a Table

  1. The Employees1 table should still be displaying in Datasheet View.
    On the ribbon, click Home if necessary.
    In the Font section, click the arrow of the Font combo box (the top-left combo box of the Font section) and click Garamond
     
    New Font Applied to a Table
  2. Press Ctrl + S to save the table

The Size of a Font

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 specify the font size of the columns, open the table in Datasheet View. On the ribbon, click Home. In the Font section, click the arrow of the Font Size combo box and select the desired size. The font size you apply to a table does not have any influence on the controls on the form(s) or report(s) that are, or will be, based on that table.

When a font is installed, a set of font sizes is created in the Font Size combo box. You can use those numbers but you can also set a new one. To do this, instead of selecting a value in the Font Size combo box, type the desired number and press Enter or Tab. The operating system would calculate the size and apply it.

Practical Learning: Setting the Font Size of a Table

  1. The Employees1 table should still be displaying in Datasheet View.
    In the Font section of the Home of the ribbon, click the arrow of the Font Size combo box (the top-right combo box of the Font section) and click 12
     
  2. Press Ctrl + S to save the table

The Style of a Font

Another aspect of the appearance of a font is its style, which a technique of drawing the characters of the text, depending on the font. This characteristic comes in four options:

Style Example
Regular Regular Text
Bold This text is bold
Italic Italicized section
Underline The words are underlined

The font style applies only to a control that can display text. When you add a text-based control to a form or a report, by default, Microsoft Access applies the Regular font style to it. you can change this characteristic if you want. To change the font style of a control, switch the form or report to Design View. Select the control or the group of controls. On the ribbon, click either Home or Design. In the Font section, click the button that represents the desired style: Bold Bold, Italic Italic, or Underline Underline.

You can specify more than one style on a control. To do this, click the button of the desired style. When a style is valid for a control, when you click that control, the style button is highlighted: Highlighted Bold, Highlighted Italic, or Highlighted Underline. To remove a style, click the undesired button. To add a style to another style, simply click the desired button. Based on this, you can one, two or three buttons highlighted in the combination of your choice.

Instead of the buttons on the ribbon, you can apply a style or a combination of styles using the Properties window. To do this, access the Properties window for the control. If you want to apply the style to many controls, select them and access the Properties window for the group of selected controls. In the Properties window, click either the Format or the All tab:

As reviewed for the style buttons on the ribbon, you can apply various styles using the Properties window. To do this, access the Properties window for the control or the group of controls and use the Font Weight, the Font Italic, or the Font Underline properties to set the styles as desired.

Practical Learning: Setting the Font Size of a Table

The Colors of Fields of a Table

 

Introduction

The color is a non-spatial characteristic applied on a Windows control or a field to define its visual density of darkness or whiteness. This density itself is a numeric value created by combining three numbers that each ranges from 0 to 255 included. The first number is 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 possible values (0 to 255), if you multiply them as 256 * 256 * 256, you get 16777216. This means that a combination of variances of red, green, and blue produces more than 16 millions of possible colors.

Font Color

There are two main aspects you will deal with as related to colors on a field or a control. The most usual way of setting a color on a field is on its characters or letters. This is also referred to as the fore color, which is simply the color of its font. There are various ways you can change the font color on a table. When displaying a table in Datasheet View, on the ribbon, you can click Home. In the Home section, click the arrow of the Font Color button. This would display a table of colors:

Font/Fore Color

By default, this window displays 2 sections of colors. The top section is labeled Access Theme Colors. The main section is titled Standard Colors. This is where you will mostly select common colors. This section is made of 10 columns and 7 rows. The intersection of a column and a row shows a colored button. Each color has a name. To see the name of a color, position the mouse on its button and a tool tip would appear.

When the list of colors displays, if you see a color you like, you can click its button. If none of the displayed colors suits your need, you can click the More Colors... button. This would display another dialog box that also allows you either to select a color or to "compose" one by combining the variances of red, green, and blue.

After a color has been selected, it displays on top of the Font Color button. Next time, if you need the same color, you can just click the Font Color button and the already selected color would be applied. In the same way, you can keep changing colors as you see fit. Whenever a color has been used in your database, it is added to the section under Recent Colors. This allows you to keep track of the colors on your objects and to be able to re-apply an already used color.

Practical Learning: Setting Text Font on a Table

  1. The Employees1 table should still be displaying in Datasheet View.
    In the Font section of the Home tab of the ribbon, click the arrow of the Font Color button (the button that displays A) and click the More Colors button
  2. In the Colors dialog box, click Custom
  3. Set the color values as follows:
     
    Red: 255
    Green: 250
    Blue: 135
    Colors
  4. Click OK
     

Managing the Grid Lines of a Table

A table in Microsoft Access appears as a classic spreadsheet with a white background and gray grid lines. If this display is not appealing, you can change it. To do this, display the table in Datasheet View. On the ribbon, you can click Home. In the Font section, click the Gridlines button Gridlines. A window would appear where you can select an option by clicking its button. If you click:

Background Color

The tables in Microsoft Office Access 2007 display their records with alternate colors. This gives them an attractive appeal. If you do not like these default colors, you can change them.

To change one of the background colors of a table, first display it in Datasheet View and click the Home button on the ribbon. In the Font section, you can click the arrow of the Fill/Back Color button. This would display a window of colors that has the same functionality as the one for the Font Color button.

To change the alternate background color of a table, while it is displaying in Datasheet View, click the arrow of the Alternate Fill/Back Color button. A window of color similar to the one we reviewed for the Font Color would appear. Its functionality is also the same. You can then select or compose the desired color.

Practical Learning: Setting Background Color of a Table

  1. The Employees1 table should still be displaying in Datasheet View.
    In the Font section of the Home tab of the ribbon, click the arrow of the Fill/Back Color button (the button that displays a pouring bucket) and click the Dark Blue color (Standard Colors: 9th column - 7th row)
  2. Still in the Font section of the ribbon, click the arrow of the Alternate Fill/Back Color button and click the Light Blue color (Standard Colors: 7th column - 7th row)
     
  3. Press Ctrl + S to save the table

Text Alignment

Most values of a database are made of regular text. Some others are meant to display numeric values, currency, dates, and times. In some cases, Microsoft Access is configured to align the values to the left or the right. In some other cases, you may want to force or customize this alignment of text. On a table, you can align the values of individual columns to the left, the center, or the right.

By default, the alignment of text-based fields, including any caption on a label, is set to the left (following US English). To apply an alignment on a table, first display it in the Datasheet View. To specify the alignment of the values of a column, click any cell under that column. On the ribbon, click Home. In the Font section, you can click:

Practical Learning: Aligning Fields Text

  1. The Employees1 table should still be displaying in Datasheet View.
    On the table, click MI
  2. On the Ribbon, click Home if necessary.
    In the Font section, click the Center button Center
  3. On the table, click any cell under Date Hired
  4. In the Font section of the Ribbon, click the Align Text Right button Align Text Left
     
  5. Save the table

Fields Management in Table Design View

 

Introduction

So far, to get acquainted with database fields, we have used two techniques of creating a table. One of the techniques we used, the Datasheet View, provided a very simplistic way. The Datasheet View is mainly used to perform data entry or to test some fields. The other technique we used, with the Table Templates, allowed us to use some already created and customized fields. For one thing, you would not know what exactly those fields are configured to do and whether they can control data entered in them. For another thing, if you do not like the way they behave, you would have to modify the configuration that was already done. This is why you should know how to design your tables.

To better control the columns of a table, we also learned to create the fields in the Design View of a table. After the columns have been created, you can perform some maintenance operations on them, such as deleting or moving them.

Practical Learning:  Introducing Table Design

  1. To create a new table, on the Ribbon, click Create
  2. In the Tables section, click Table
  3. To save the new table, right-click the Table1 tab and click Save
  4. Set the name to Customers and click OK
  5. Double-click Add New Field, type Customer and press Tab
  6. Type Brought a Car and press Tab
  7. Type Tag Number and press Enter
  8. To switch the table to Design View, on the right side of the status bar, click the Design View button

Field Renaming

One of the jobs involved with database maintenance is to review fields and make sure they are explicit enough for the user. There are three issues related with a field's name. Some fields, as you will find out are involved in relationships, and you will have to be careful when deciding to change their name. The other issues are related to a field's actual name and its caption.

A field's name is mainly made of two parts from the developer's standpoint: the actual name and the caption. A field's name is stored as part of the table and is involved with any business dealing the table has to cope with. The caption simply guides the user in identifying the use of a particular field. These two items are not strictly related. For example, you could have a field whose name is SocSecNbr while its caption displays Nat Number From Gvt and this will not affect the functionality of the table. Overall, as a developer, you should pay attention to your fields names because these are the names you will refer to when performing calculations or when creating expressions.

To rename a field in Datasheet View, use any of the techniques we learned to change a column's name. After you have typed the name, the new name will replace the old one. To rename a field in Design View, click it and type the new name.

Practical Learning: Renaming a Field

  1. Under Field Name, double-click Customer and type Full Name
  2. Press the up arrow key to select ID and type Customer ID
  3. Press the down arrow key twice to select Brought a Car and type Has Car
  4. Press Ctrl + S to save the table

Field Insertion

In a table's Design View, you can insert a new field at any position. You can also add a new field to the end of the table:

Practical Learning: Inserting New Fields in Table Design View

  1. Right-click Has Car and click Insert Rows
  2. Type Billing Address as the name of the new column
  3. Press the down arrow key
  4. Press Insert
  5. Type Billing City and press Enter three times
  6. Press Insert and type Billing State
  7. Click Has Car
  8. On the ribbon, click Design
  9. In the Tools section of the ribbon, click the Insert Rows button
  10. Type ZIP or Postal Code and press Tab three times
  11. Again, in the Tools section of the ribbon, click the Insert Rows button
  12. Type Country
  13. Click the first empty box under Tag Number and type Requires Handcap Assistance
  14. Press the down arrow key and type Email Address
  15. Save the table

Field Selection in Table Design View

In the Design View of the table, there are various types of operations you can perform for database maintenance. Operations include naming or renaming fields, moving or deleting fields, and changing various other properties. In order to perform some of the operations on a field, you must first select it. If the desired operation involves a group of fields, you must first select them:

Column Moving in Table Design View

The columns of a table are displayed in the sequence in which they were created. In Lesson 2, we learned how to move columns and change their sequence in Datasheet View. You can also change the sequence of fields in the Design View of a table.

Practical Learning: Maintaining Fields in Table Design View

  1. The Customers table of the Hotel Management1 database should still be opened in Design View.
    Click the button on the left side of Requires Handcap Assistance
  2. Click that button again but hold your mouse down
  3. Drag it up until the guiding horizontal line is positioned under Customer ID
     
  4. Release the mouse
  5. Save the table

Field Deletion

When in Design View, you can delete a field you don't need anymore or if it was added by mistake. To delete a column:

To delete a group of columns, first select them, then:

Practical Learning: Deleting a Field in Table Design View

  1. To get rid of a column, right-click Requires Handcap Assistance and click Delete Rows
  2. Click Email Address
  3. On the ribbon, if necessary, click Design.
    In the Tools section, click the Delete Rows button
  4. Save the table

Lesson Summary

 

MCAS: Using Microsoft Office Access 2007 Topics  
C2 Create tables
E1 Enter, edit, and delete records
 

Exercises  

Yugo National Bank

  1. Open the Yugo National Bank
  2. Using the Table button of the Creation section of the Ribbon, start a new and change Add New Field to ChargeReason
  3. Rename the ID column to ChargeReasonID
  4. Save the table as ChargeReasons and close it

US Senate

  1. Open the US Senate1 database
  2. Using the Table button of the Creation section of the Ribbon, start a new and change Add New Field to SenatorName
  3. In the same way, add two more columns named SeatingStatus and Gender
  4. Rename the ID column to SenatorID
  5. Save the table as Senators and close it

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