Using Field Size Properties to Restrict Data


Using Field Size Properties 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 that 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:

Setting

Description

Byte

Stores numbers from 0 to 255 (no fractions).

Integer

Stores 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).

Single

Stores numbers from “3.402823E38 to “1.401298E “45 for negative values and from 1.401298E “45 to 3.402823E38 for positive values.

Double

Stores numbers from “1.79769313486231E308 to “4.94065645841247E “324 for negative values and from 1.79769313486231E308 to 4.94065645841247E “324 forpositive values.

Decimal

Stores numbers from -10^28 -1 through 10^28 -1.

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 the impact this has on data already in the table and on new data that you enter.

USE the FieldTest database in the practice file folder for this topic. This practice file is located in the  My Documents\Microsoft Press\Office 2003 SBS\Accurate\FieldSize folder and can also be accessed by clicking Start/All Programs/Microsoft Press/Microsoft Office System 2003 Step by Step .

OPEN the FieldTest database.

  1. Open the Field Property Test table in Design view.

  2. Click in the TextField row, and in the Field Properties area, change the Field Size property from 50 to 12 .

  3. Click in the NumberField row, click the Field Size property, click its down arrow, and change the setting from Long Integer to Byte .

    The number of characters that can be entered in the text field is restricted to 12, and the values that can be entered in the number field are restricted to the range0 to 255.

  4. Click the View button to return to Datasheet view, clicking Yes when prompted to save the table.

    The table contains data that doesn t fit these new property settings, so Access displays a warning that some data might be lost.

    click to expand
  5. Click Yes to acknowledge the risk, and click Yes again to accept the deletion of the contents of one field.

    click to expand

    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 through 255 , and the value of 500 that you entered was deleted.

  6. Type 2.5 as the NumberField entry, and press [ENTER].

    The number is rounded to the nearest whole number.

  7. Close the table.

CLOSE the FieldTest database.




Microsoft Office 2003 Step by Step
MicrosoftВ® Office ExcelВ® 2003 Step by Step (Step By Step (Microsoft))
ISBN: 0735615187
EAN: 2147483647
Year: 2005
Pages: 350
Authors: Curtis Frye

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