![]() |
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. |
|
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:
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:
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:
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:
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.
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:
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:
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 consists of adding one between two existing fields. There are various ways you can do this:
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:
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:
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.
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:
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.
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:
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. 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.
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:
|
|
|
||
| Home | Copyright © 2008 FunctionX, Inc. | |
|
|
||