Section 2.1. Understanding Data Types


2.1. Understanding Data Types

All data's not created equal. Consider the Dolls table you created in Chapter 1 (Section 1.2.3). Its fields actually contain several different types of information:

  • Text . The Character and Manufacturer fields.

  • Numbers . The ID and PurchasePrice fields.

  • Dates . The DateAcquired field.

You may naturally assume that the PurchasePrice field always includes numeric content, and the DateAcquired field always includes something that can be interpreted as a date. But if you haven't set the data types correctly, Access doesn't share your assumptions, and doesn't follow the same rules.

When you create a new field in Datasheet view, Access makes an educated guess about the data type by examining the information you've just typed in. If you type 44 , then Access assumes you're creating a number field. If you type Jan 6, 2007 , then Access recognizes a date. However, it's easy to confuse Access, which leads to the problems shown in Figure 2-1.

Figure 2-1. Here, Access doesn't recognize the date format used for the DateAcquired field when it was created. As a result, Access treats that field as ordinary text. You can enter dates in several different formats (which makes the DateAcquired information harder to read and impossible to sort ). You also let in completely nonsensical entries, like "fourscore bananas."


In order to prevent invalid entries, you need to tell Access what each field should contain. Once you set the rules, Access enforces them rigorously. You put these requirements in place using another windowthe Design view of your table.



Access 2007[c] The Missing Manual
Access 2007[c] The Missing Manual
ISBN: 596527608
EAN: N/A
Year: 2007
Pages: 153

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net