Home Access 2002 Data Types Learn How To Choose Data Types   |   Search MS Office A-Z   |   Search Web Pages/ Design A-Z

Learn How To Choose Data Types

You can enter all kinds of information into an Access database. Text, numbers, hyperlinks, images, dates, charts, and other types of data can all be included.Simply being able to input data isn’t much use, though, if you can’t manipulate it. You want to find records before or after a certain date, calculate averages and percentages of dollar amounts, open Web sites directly from a form, and so on.

To complete these and the thousands of other tasks Access is equipped to handle, you need to choose the appropriate data typefor each kind of information in your database. You usually select data types as you create fields in a new table. Although it’s possible to change a data type later on, it’s often a difficult and unwieldy process.

Because choosing data types is an essential Access skill, let’s spend some time finding out more about them.

 Create A Table

Choose File and New. In the New section of the on-screen menu, click Blank Database. In the File New Database window, select a folder in which to save your database. At the bottom of the window in File Name, type Smart Computing Exampleand click Create. In your new database, double-click Create Table In Design View.

We’ll make a table with information about your business contacts. Because the goal is to learn about various data types, rather than to create a usable database, your completed table will be somewhat contrived and slapdash. You should carefully plan a real database, which usually involves making several tables and establishing relationships among them.

 Create Fields

We’ll start by entering a few fields with basic contact information. In the first row of the Field Name column, type FirstName. Press TAB to move to the Data Type column. The default choice is Text, the most common data type. You can use text fields to store data with text or any combination of text and numbers. Because names are composed entirely of text, the Text data type is the obvious and best choice. Press TAB.

You can use the Description column for notes about the field that you may want to include. It’s entirely optional, and it doesn’t affect your data. The field properties in the lower pane are a different matter, however; they’re an integral part of the field, and you’ll want to consider and edit them carefully. For this exercise, though, we’ll accept all of the default settings.

Press TAB to move the cursor to the next row. Type LastNameand press TAB. Like FirstName, this field is entirely text, so press TAB twice to accept the Text data type and move to the next row.

 When A Number Is Text

 

Type Telephoneto include a field for the phone number and press TAB. Click the down-arrow button to view the data types available. Among them is Number, which seems a logical choice for the phone number field.

Logical, but wrong. A Number field can contain only numbers; even the dash in a phone number, such as 555-2266, isn’t acceptable. In Access, you use the Number field only when you want to perform arithmetic: addition, subtraction, averages, etc. It’s unlikely you’ll want to find the standard deviation of a set of phone numbers, fax numbers, or ZIP codes.

If a phone number is not a Number, what is it? The answer, again, is Text. You can use the Text field for any string of alphanumeric characters: The Great Highway, 49 Elm St., Apt. 654J, and 555-2266. With Text still selected, click the down-arrow button to close the list and press TAB twice to move to the next row.

 Date/Time & Yes/No

Type Birthdayfor the contact’s date of birth and press ENTER. Click the down-arrow button and choose Date/Time. There are several advantages to using a Date/Time field for dates. Most significantly, you can input the date in a variety of ways. If you want to enter the sixth day of March for the year 1998, Access accepts 3/6/98, 6 March 1998, or March 6, 1998. Press TAB twice to move to the next row.

Type Citizen to create a field that will tell you whether the contact is a U.S. citizen. Press TAB, click the down-arrow button, and choose Yes/No. The Yes/No field allows only two values: it’s either positive (Yes, True, On) or negative (No, False, Off). This field asks the question "Is this person a U.S. citizen?," which can be answered by a yes or a no. So the Yes/No data type is the best choice. Press ENTER twice.

 Currency, Hyperlink & Memo

Type Salary for the contact’s weekly salary. Press TAB, click the down-arrow button, and choose Currency. When you use the Currency data type, Access will add the unit of currency (the $ sign is the default) and decimal places. The Currency data type also lets you perform arithmetic on the field’s values. Press ENTER twice.

Type BestSiteto enter the URL (uniform resource locator) of the contact’s favorite Web site. Press TAB and select Hyperlink from the list (click the down-arrow button). When you click a value in the Hyperlink field, Access will open it in your browser. Press TAB twice.

Type Biographyto create a field for the contact’s personal history. Press TAB and select Memo from the list (click the down-arrow button). Why choose Memo and not Text? Although the Text data type is limited to 255 characters, a Memo field can contain more than 65,000. If you think you may need to input a lot of text, Memo is the preferred choice.

 Save The Table

Click Save, type Contactsin the TableName field, and click OK. Access asks you if you want to include a primary key. Click Yes. Access adds a new field in the first row called ID, which has the AutoNumber type. Each time you add a new record, Access automatically enters a numerical value for this field that is one more than that for the previous record.

This discussion of data types (especially for primary keys) is introductory at best, but it should give you a feel for the major data types. In Figure 2, we’ve entered a couple of records so you can see what the information in each field looks like. Please remember to delete the Smart Computing Example database if you’d prefer not to have it on your hard drive.