Training
Certifications
Books
Special Offers
Community




 
Microsoft® Access Version 2002 Step by Step
Author Online Training Solutions, Inc.
Pages 352
Disk 1 Companion CD(s)
Level Beg/Int
Published 06/06/2001
ISBN 9780735612990
Price $29.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Index
Related Series
Related Books
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 


Chapter 6: Keeping Your Information Accurate continued


Using the Field Size Property to Restrict Data

You can set the Field Size property for the Text, Number, and AutoNumber data types. This property restricts the number of characters you can enter in a text field and the size of numbers that can be entered in a number or AutoNumber field. For text fields, the Field Size property can be set to any number from 0 to 255. AutoNumber fields are automatically set to Long Integer. Number fields can be set to any of the following values:

SettingDescription
ByteStores numbers from 0 to 255 (no fractions).
IntegerStores numbers from –32,768 to 32,767 (no fractions).
Long Integer(The default.) Stores numbers from –2,147,483,648 to 2,147,483,647 (no fractions).
SingleStores numbers from –3.402823E38 to – 1.401298E–45 for negative values and from 1.401298E–45 to 3.402823E38 for positive values.
DoubleStores numbers from –1.79769313486231E308 to –4.94065645841247E–324 for negative values and from 1.79769313486231E308 to 4.94065645841247E–324 for positive values.
DecimalStores numbers from -10^28 -1 through 10^28 -1 (.mdb).

By setting the Field Size property to a value that allows the largest valid entry, you prevent the user from entering certain types of invalid information. If you try to type more characters in a text field than the number allowed by the Field Size setting, Access beeps and refuses to accept the entry. Likewise, a value that is below or above the limits of a number field is rejected when you try to move out of the field.

In this exercise, you will change the Field Size property for several fields to see what impact this has on data already in the table and on new data you enter. The working folder for this exercise is SBS\Access\Accurate\FieldSize. Follow these steps:

  1. Open the Field Test database located in the working folder.
  2. Open the Field Property Test table in Design view.
  3. Click in the TextField row, and in the Field Properties section, change the Field Size property to 12.
  4. Click in the NumberField row, click the Field Size property, click its down arrow, and then click Byte in the drop-down list.
  5. You have just restricted the number of characters that can be entered in the text field to 12 and the values that can be entered in the number field to the range 0 to 255.

  6. Click the View button to return to Datasheet view, clicking Yes when prompted to save the table.
  7. The table contains data that doesn’t fit these new property settings, so Access displays a warning, shown on the next page, that some data might be lost.

    Click to view graphic
    Click to view graphic

  8. Click Yes to acknowledge the risk, and click Yes again to accept the deletion of the contents of one field.
  9. Your datasheet now looks like this:

    Click to view graphic
    Click to view graphic

    TextField now contains only 12 characters, rather than the 32 you entered. The other 20 characters have been permanently deleted. NumberField is empty. Because it is now limited to whole numbers from 0 through 255, the value of 500 that you entered has been deleted.

  10. Type 2.5 as the NumberField entry, and press Enter to see what happens.
  11. The number is rounded down to the nearest whole number.

  12. Close the table, and then close the database.


Previous   |  Table of Contents   |   Next




Top of Page


Last Updated: Saturday, July 7, 2001