2. Restricting the Amount of Data
You changed the Field
Size property of several Text fields. You entered the new sizes by
making adjustments to the Field Size setting in the Properties group
on the Fields tab and to the Field Size property in the Field
Properties area in Design view. As you saw, changing the size of a
Text field is a simple matter of estimating the largest number of
characters you will need to type in the field, up to 255.
Like the Text data type, the AutoNumber and Number data types
have an associated Field Size property that restricts the number of
digits that can be entered in the field. Of the two, the Field Size
property of the Number data type is the most complex. You can set
Number fields to any of the settings shown in the following
table.
The Field Size property of AutoNumber fields can be set to
either Long Integer (the default) or Replication ID.
By setting the Field Size property to the setting that allows
the largest valid entry, you prevent the entry of invalid values.
Access rejects any value that is below or above the size limits of the
field when you try to move out of the field.
See Also
For more information about data restrictions, search for
Introduction to data types and field properties
in Access Help.
In this exercise, you’ll change the Field Size property for two
fields to see the impact on data already in the table and on new data
that you enter.
Set Up
You need the GardenCompany06 database you worked with
in the preceding exercise to complete this exercise. Open the
GardenCompany06 database, and display the FieldTest table in
Datasheet view. Then follow the steps.
-
Review the field values in the only record in the FieldTest table.
-
Switch to Design view, click anywhere in the fText row, and then in the Field Properties area, change the
Field Size property from
255 to 18.
Access will now restrict the number of characters that can
be entered in the fText field to 18.
-
Click any cell in the fNumber row, click anywhere in the
Field Size property, click the
arrow that appears, and then in the list, click Byte.
Access will restrict the values that can be entered in the
fNumber field to the range 0 through 255 (inclusive).
-
Switch to Datasheet view, clicking Yes when prompted to save the
table.
Access displays a warning that some data might be
lost.
-
Click Yes to acknowledge
the risk, and click Yes again
to accept the deletion of the contents of one field.
-
Double-click the right border of the fText field to widen the column to fit
its entry.
You can now see the impact of the field size changes on the
fields.
You entered 32 characters in the fText field, and it
can now hold only 18. So 14 characters have been permanently
deleted. You entered 500 in the fNumber field, and it can now hold
only whole numbers from 0 through 255. So the value has been
permanently deleted.
-
In the fNumber field,
type 2.5, and press Tab.
Access rounds the value you entered to the nearest whole
number. Because you chose Standard when setting the data type for
this field in the previous exercise, the whole number is displayed
as 2.00.
Clean Up
Close the FieldTest table, saving your changes. Retain the
GardenCompany06 database for use in later exercises.