Part 3 of "Keeping Your Information Accurate in Access 2003 and Access 2002": Using the field size property to restrict data (311169)
The information in this article applies to:
- Microsoft Office Access 2003
- Microsoft Access 2002
This article was previously published under Q311169 SUMMARY The information covered in this article is provided by the
Microsoft Press. For more information, visit the following Microsoft Web site: This article is part 3 of a series of eight
articles that explain how to keep your information in Access accurate. To view
the other articles in this series, see the "Additional resources"
section later in this article. This information is an excerpt from chapter 6: "Keeping Your Information Accurate" of
the book Microsoft Access Version 2002 Step by Step. For more information about this book, see the "References" section. MORE INFORMATION 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 can be set to Long Integer or Replication ID. They are set to Long Integer by default. 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 for
positive values.
Decimal Stores numbers from -10^28 -1 through 10^28 -1 (.mdb).
Replication ID Globally unique identifier (GUID). A 16-byte field used
in an Access database to establish a unique identifier
for replication. GUIDs are used to identify replicas,
replica sets, tables, records, and other objects. In an
Access database, GUIDs are referred to as Replication
IDs. 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. Follow these steps:
- Open the Field Test database that you created in Part 2 of this series of articles.
For
additional information, click the article number below to view the article in
the Microsoft Knowledge Base:
311168 ACC2002: Keeping Your Information Accurate: Part 2: Using the Data Type to Restrict Data
- Open the Field Property Test table in Design view.
- Click in the TextField row, and in the Field Properties section, change the Field Size property to 12.
- Click in the NumberField row, click the Field Size property, click its down arrow, and then click Byte in the drop-down list.
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. - 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 Yes to acknowledge the risk, and click Yes again to accept the deletion of the contents of one field.
Your datasheet now looks like this:
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. - Type 2.5 as the NumberField entry, and press ENTER to see what happens.
The number
is rounded down to the nearest whole number. - Save and close the table, and then close the
database.
ADDITIONAL RESOURCES
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
311167
Part 1 of "Keeping Your Information Accurate": Introduction for Access 2003 and Access 2002
311168 Part 2 of "Keeping Your Information Accurate": Using the data type to restrict data in Access 2003 and Access 2002
311169 Part 3 of "Keeping Your Information Accurate": Using the field size property to restrict data in Access 2003 and Access 2002
311171 Part 4 of "Keeping Your Information Accurate": Using an input mask to restrict data in Access 2003 and Access 2002
311172 Part 5 of "Keeping Your Information Accurate": Using validation rules to restrict data in Access 2003 and Access 2002
311173 Part 6 of "Keeping Your Information Accurate": Using a lookup list to restrict data in Access 2003 and Access 2002
311174 Part 7 of "Keeping Your Information Accurate": Updating information in a table in Access 2003 and Access 2002
311175 Part 8 of "Keeping Your Information Accurate": Deleting information from a table in Access 2003 and Access 2002
REFERENCES The information in this article is an excerpt from the Microsoft Access Version 2002 Step by Step book, published by Microsoft Press.
To learn more about
the Microsoft Access Version 2002 Step by Step book, and to see a sample chapter from this book, visit the following Microsoft Web site: For more information
about this publication and about other Microsoft Press titles, visit the following Microsoft Web site:
Modification Type: | Minor | Last Reviewed: | 7/7/2004 |
---|
Keywords: | kbinfo KB311169 kbAudDeveloper |
---|
|