Microsoft KB Archive/207471

= ACC2000: You Receive No Warning When a Number Is Too Large for a Single Data Type =

Article ID: 207471

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q207471



Novice: Requires knowledge of the user interface on single-user computers.

This article applies only to a Microsoft Access database (.mdb).



SYMPTOMS
If you type a value into a field whose data type is Single, and that value is greater than what the Single data type allows, you do not receive a warning message. Instead, Microsoft Access automatically replaces the value that you typed with the largest possible value allowed by the data type.



CAUSE
This behavior is caused by a rounding error that can occur when a decimal fraction does not have an exact binary equivalent. For additional information about rounding errors, click the article number below to view the article in the Microsoft Knowledge Base:

210423 ACC2000: Rounding Errors When You Use Floating-Point Numbers



RESOLUTION
Create a validation rule if you want a warning to appear when you have typed a number that is too large or too small for the data type of the field.

Example of a Validation Rule
 Follow steps 1 and 2 in the "Steps to Reproduce Behavior" section later in this article. After setting the format to General Number, set the following properties for the TestSingle field:

Validation rule: Between 3.402823E+38 and -3.402823E+38

Validation text: You have entered a number that is larger than the Field Size setting permits.





MORE INFORMATION
The range of a single-precision floating-point number is from -3.402823E38 to -1.401298E-45 for negative values and from 1.401298E-45 to 3.402823E38 for positive values.

Steps to Reproduce Behavior
 Start Microsoft Access, and then open any database.  Create the following table, and name it tblTestType: <pre class="fixed_text">  Table: tblTestType --  Field Name: TestSingle Data Type: Number Field Size: Single Format: General Number </li> On the File menu, click Save. In the Save As dialog box, type tblTestType. When you are prompted to create a primary key, click No.</li> On the View menu, click Datasheet.</li> On the Tools menu, click Options, and then click the Keyboard tab. Under Move After Enter, click Don't Move, and then click OK.</li> Type the following number in the first record:

3.4028235E+38

Press ENTER. Note that you receive no message that the number is too large for this field; however, the "5" is removed without prompting, and the number is changed to the largest number appropriate for the Single data type. This behavior also occurs if you type the following number:

-3.4028235E+38

However, when you type the following number

3.4028236E+38

you receive the following error message:

The value you entered isn't valid for this field.

For example, you may have entered text in a numeric field or a number that is larger than the FieldSize setting permits.

</li></ol>

<div class="references_section">