Introduction to Data Types |
|
Overview of Data Types
Introduction
A data type represents the kind of information that a particular field should or must hold. Every field in your database objects (tables, forms, and reports) should have the right type and it is your role to select the most appropriate of them. This helps both you and the user who performs data entry. Furthermore, a good design will cause you less headache when |
creating calculated expressions. Imagine trying to
multiply a FirstName by a DateHired. As much as you can, you should make
sure that the right kind of data is typed in the right field.
Microsoft Access helps you allow or exclude categories of data in database
fields. Using this, you can make sure that the user would not type a
contract's date in a project's contact name. To manage different forms of
information you enter in a database, Microsoft Access helps you organize
data by categories.
Techniques of Controlling Data Entry Properties
To make your database efficient, in some circumstances, or depending on the project (or customer), you should exercise as much control as possible on data entry. Without considering that data entry people are not intelligent enough, it is your job to help or guide them by allowing the right type of information in a field. This control is mostly exercised at two levels: tables and forms.
To control data entry at the table level, a database environment like Microsoft Access provides data types. To specify a data type for a field on a table, you must open the table in Design View and select a data type under the Data Type column for the corresponding column. Because the list of data types may appear short to you, each data type provides some options that allow you to configure how data in that column either would be selectively entered or would display. To do this, after selecting a data type in the Data Type combo box, in the lower section of the table, you can format or further configure the column.
After a field has been configured on a table, when that field is used in a form, it would respect the formatting that was done on the table. Even if you create an unbound field on a form, you can still control how it accepts or rejects data. Therefore, data entry can also be configured at the form level. To provide this functionality, a form provides the same properties as the lower portion of the table.
To further control how data is entered and/or how it is displayed in a field, both the table in Design View and the Properties window in Form Design provide special
characteristics.
The lower part of the table Design View is made of two sections: the property pages on the lower left and the properties help section on the lower
right:
The kind of Data Type you set for a column in the upper section controls what displays in the lower section of the view. The
General property page controls regular features common to the selected data type:
Field Size: The Field Size property is available for a data type and since data types are specified only on a table, it is available only on a table. The
Field Size depends on the type of data selected but it is available only for text and numbers.
Format: The Format property is used to specify how the value(s) for a
column should display.
The Lookup tab allows you to specify a feature that is particular with a specific data type of the upper section of the field.
Once you have selected a data type for a certain field in the upper section of the view, that data type will provide its own sub-categories. To display the sub-categories of a data type, select that data type in the upper section of the view.
Strings and Data Types |
Introduction |
We have defined a string as an empty text, a letter, a word or a group of words considered “as is”. This type of data is created on a table by selecting the Text data type. A Text data type allows the user to type any kind of characters or group of characters. This field can hold up to 255 characters. |
Practical Learning: Setting Appropriate Data Types
|
Field Size |
The size of a string is usually considered as the number of characters it contains or may hold. When creating a field that would hold text, the default size provided is 50 characters, as the number 50 is set in the Field Size property. You can therefore decrease or increase this size for any number between 1 and 255. The default value, 50, is enough in most cases, such as providing a (short) description for a product. When setting the Field Size property by itself, the database would make sure that the user can only type so many characters. For example, it is very unlikely to have a first name of a person that is 50 characters. In this case, you can safely reduce the number of characters to 20 or 30. On the other hand, if you are creating a column whose length is hard to predict, you can set the length to a reasonable value. There are other ways you can decrease the number of characters that are allowed in a field. Over all, you should be able to predict the types of values that would be entered in the fields of a column. |
Practical Learning: Setting Field Sizes
|
Text Input Masks |
Because users can be tempted or distracted to enter just anything in a Text field, Microsoft Access provides techniques to control what goes in a field and what must be prevented. This is the role of a mask. A mask is a technique of creating sections, also called placeholders, in a field. A section can be configured to accept only a letter, only a digit, a character or a digit, any symbol, nothing, or to display a particular symbol that the user cannot change. When creating the mask, you will use some predefined characters and create a combination of your choice. Once you have located the desired mask, you can click it and click Next to continue. If none of the masks suits your need, you can create a new one and add it to the list. To do this, click the Edit List button. This would bring the Customize Input Mask Wizard dialog box: After creating a new mask, click Close. Once you have located the desired mask, you can click it and click Next to continue. The second page of the wizard allows you to accept or customize the mask you had selected. Once you are ready, you can click Next. The third page presents an option that allows you to specify how the value in the field will be stored in the database. It presents two radio buttons and you can either accept the suggestion or select the other and click Next. The fourth page of the wizard does not do much. It simply lets you know that the wizard is ready to create the mask. Therefore, you can click Finish. |
|
You can use any of these symbols to create a mask. If you want to include a word or sentence as part of the mask, type it in any section as desired. Here are examples of Custom Masks: |
|
Practical Learning: Using Input Masks
|
Strings Formats |
After a user has entered data in a field, without or without the influence of a mask, you can specify how the value of the field should be displayed. This is controlled by the Format property. To assist you with this configuration, the Format property depends on the type of data set for the field. After creating a mask, if you want to prevent duplicate data, remember to specify this in the Indexed property. |
Practical Learning: Setting Fields Format
|
The Memo Data Type |
The Memo data type is like the Text type except that it can hold a longer text up to 64000 characters. The text is mostly provided as ASCII. This means that there is no formatting. |
Practical Learning: Setting Memo Types
|
MOUS Topics |
S1 | Determine appropriate data inputs/outputs for your database |
S12 | Use multiple data types |
S15 | Use the Input Mask Wizard |
Exercises |
Yugo National Bank
|
Tenley Associates
|
Watts A Loan
|
|
||
Previous | Copyright © 2002-2016, FunctionX, Inc. | Next |
|