Home

The Columns of a Table

 

Tables Columns in the Datasheet View

 

Creating a Column

 

Although we didn't mention it so far, a table does not exist without a column. Put it another way, a table must have a least one column in order to have meaning. This also means that, in order to create a table, it must actually have at least one column. If you start a table in Datasheet View, Microsoft Access creates and gives it one default column. Once a table displays in Datasheet View, you can start entering data into its cells. If you do this, whenever you enter data under a column, that column receives an incremental name: the first column on the right side of ID would be named Field1, the second would be Field2, and so on. These would be insignificant and can even be confusing. Fortunately, you can give meaningful names to the columns of your table.

Naming a Column

A column can have almost any name: "Book Title", "DG$5@H", "This Is The Book Title", "R8%%DW$4", etc. Some columns will have only tinny data, like a person's age, the number of books in an office, a person’s middle initial, etc. It may not be a good idea to give them a name that would take too much space. In the future, when you start programming, it would be easier to handle field names that are composed of only one word, without space.

To name a field, first figure out what the data in the category will be made of. If you are planning to enter employees' salaries in a field, you can just call it Salary. If you want to specify employees’ names by first name, middle name, and last name, you can use such column names and make them distinct. In this case, you could name the first column as first name, the last name would be called last name. Although you can use one word names, some people might be confused. The suggestion is to distinguish wherever a new English (or the language you are using to design your database) name starts in the field name, by using a starting uppercase. Instead of firstname or first name, you can use FirstName or First Name. Instead of fullname or full name, you can use FullName or Full Name.

Before changing the name of a column:

  • You can double-click its header
  • You can right-click a column and click Rename Column
  • When any cell under a column has focus, on the ribbon, you can first click Datasheet. Then, in the Fields & Columns section, click Rename Column. 

Any of these actions would put the name of the column into edit mode. You can then type the new desired name or change the existing name:

Table in Datasheet View

Using a Template Field

If you create a table using one of the templates, it would have ready-made fields. If you create a table from scratch, it may lack some fields. Fortunately, Microsoft Access provides many pre-configured fields you can add to your table, whether you create the table based on a template or from scratch. These ready-made sample columns are referred to as a Field Templates.

Before using a field template, from the ribbon, click Create and click New Table. This would start a new table and the ribbon would switch to the Datasheet tab. In the Fields & Columns section, click New Field. This would display the Field Templates window:

Field Templates

By default, the Field Templates window is positioned on the right side of the screen. This is a dockable window: you can move it to the left or place it somewhere else on the screen.

The items in the Field Templates window are organized in categories identified with a labeled node, such as Basic Fields, Assets, or Contacts. Each node displays a - button. This - button indicates that the node is expanded. To collapse a node, you can click its - button, which becomes a + button. To expand a node, you can click its + button. Here is an example where the Assets, the Contacts, and the Issues nodes are collapsed while the Events and the Projects nodes are expanded:

To use a field from the Field Templates window:

  • You can double-click the field
  • You can click and drag the field from the Field Templates and drop it on the table to the left of Add New Field:
     

Columns Maintenance in the Datasheet View

 

Importing a Table and its Columns

Although a column completely depends on a table, both objects are closely related when it comes to their maintenance. In other words, the maintenance performed on one object can directly affect the other. For example, you can import a table from a text file or from another application. A table cannot exist without at least one column.

Selecting a Column

Some operations will require that you select a column but it depends on the operation. In some cases, when any cell under a column has focus (for example if the caret is blinking in a cell of a column), the column is considered to be selected. Otherwise:

  • To select one column, position the mouse on its name until the cursor points down and then click
     
    Cursor
  • To select columns in a range, click and hold your mouse on one of them, then drag to the left or to the right to cover the other desired column or columns. When all desired columns are highlighted, release the mouse
  • To select a range of columns, click one column that will be at one end, press and hold Shift, then click the column that will be at the other end, and release Shift

Changing the Width of a Column

If you create a table using one of the Table Templates or if you get a table from a Database Template, the columns of the tables are wide enough to show their names. If  you create a table from scratch in the Datasheet View, Microsoft Access assigns it a default width. That width can appear to be too narrow or too wide. For example, when data exceeds the regular width of a column, part of the information would be hidden. If a particular column contains data that you want to display at all times, you can enlarge the column. On the other hand, if a column displays tinny pieces of information, you can narrow the column to let it just fit the data as desired. There are various techniques you can follow to widen or narrow a column.

To change the width of a column:

  • you can position the mouse on the right border of a column header. The mouse pointer would change into a horizontal double arrow crossed by a vertical line:
     

     
    If you double-click, the column would be resized to the widest value of the column, provided the widest value is wider than the column header. If the widest value is narrower than the column header, the column width would be widened enough to display the name of the column.
  • You can click the column's right border and drag in the desired direction, left or right until you get the desired width
     
  • You can right-click a column's name and click Column Width... This would open the Column Width dialog box where you can type the desired value and click OK
     
    Column Width

Moving a Column

If you find out that a particular column is misplaced in a table, you can change its position.

To move a column in Datasheet View, first select it, click and hold your mouse on it. Then, start dragging left or right in the desired direction. While your mouse is moving, a thick vertical line will guide you. Once the vertical line is positioned to the desired location, release the mouse:

To move a group of columns, first select them as we reviewed earlier, click and hold the mouse on one of the selected columns, start dragging left or right in the desired direction until the thick vertical guiding line is positioned in the desired location, then release the mouse:

Inserting a Column

Inserting a column consists of adding one between two existing fields. There are various ways you can do this:

  • To insert a column using the ribbon, first click a cell under the column that will succeed it. Then, in the Fields & Columns section of the Datasheet tab, click the Insert button Insert
  • To insert a column from the table, right-click the column that will succeed it and click Insert Column
  • To insert a field from the Field Templates, click and drag it from the Field Templates and drop it to the left of the column that will succeed it
     
    Inserting a Column

Renaming a Column

We saw various techniques of naming a column. You can use the same approach to change the name of a column. To put the name of a column into edit mode and then change it:

  • You can double-click its name on the header
  • You can right-click the column's name and click Rename Column
  • When any cell under the column has focus, on the ribbon, click Datasheet, in the Fields & Columns section, click the Rename button Rename

Hiding and Revealing a Hidden Column

If a table contains many columns and at one time you think you don't need all of them, you can hide some. To hide a column, you can drag the right border of its column header completely to its left border as we saw earlier to change the width of a column; when the vertical guiding line reaches the left border, release the mouse: the column would be hidden from the table:
 

 
 

To hide one or a group of columns, you can right-click and click Hide Column. You can also right-click any column and click Unhide Column. This would open the Unhide Columns dialog box. Here is an example:

Unhide Columns

To hide a column, clear its check box.

To reveal a column or a group of columns previously hidden, right-click any column header on the table and click Unhide Column. In the Unhide Columns dialog box, put a check mark on each column you want to show.

Deleting a Column

If you have an undesirable column in a table, you can delete it. It is important to keep in mind that if you delete a column, it also goes with any information under it.

To remove a column from a table:

  • You can right-click the column's name and click Delete Column
  • You can select the column (or a group of columns), right-click anywhere in the table and click Delete Column
  • You can select a column (or a group of columns). Then, in the ribbon, click Datasheet. In the Fields & Columns section, click the Delete button Delete

Any of these actions would present you a warning to confirm whether you still want to delete the column(s) or you want to change your mind. If you still want to remove the column(s), click Yes.

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:

  • To create a new column and give it a name, click an empty cell under Field Name and type the desired name
  • To change the name of an existing column, double-click its name in the Field Name column to select it and type the desired name
  • To edit the name of an existing column, click somewhere in the name to put it into edit, use the Delete, the Backspace, and the arrow keys to edit it

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.

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:

  • To specify the caption of a field, in the top section of the Design View, click the field under the Field Name column. In the lower section of the window, click Caption and type the desired word or group of words
  • To change the caption of a column but keep its name, switch the table to Design View, under Field Name, click the field. In the lower section of the window, click Caption, press F2 and edit the string
 

Home Copyright © 2008 FunctionX, Inc.