Microsoft KB Archive/181155

= ACC: Number Changed Without Warning When Number Is Too Large for Single Data Type =

Article ID: 181155

Article Last Modified on 1/22/2007

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q181155



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



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



CAUSE
This behavior is caused by a rounding problem that can occur when a decimal fraction does not have an exact binary equivalent. For further information, please see the following article in the Microsoft Knowledge Base:

111781 ACC: Rounding Errors Using Floating-Point Numbers



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

Example of a Validation Rule
 Repeat 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 on the TestSingle field:

     Validation rule: <=3.402823E+38 Validation text: The number you entered is too large for this field. 



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

Steps to Reproduce Behavior
 Start Microsoft Access and open any database.  Create the following table named 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 view.</li> If you are using Microsoft Access 7.0 or 97, click Options on the Tools menu, and then click the Keyboard tab. Under Move After Enter, click Don't Move, and then click OK.

If you are using Microsoft Access version 2.0, click Options on the View menu. Click Keyboard in the Category list and set Move After Enter to No. Then click OK.</li>  Type the following number in the first record:

<pre class="fixed_text">     3.4028235E+38

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

<pre class="fixed_text">     -3.4028235E+38

However, you receive the expected error message when you enter the following number:

<pre class="fixed_text">     3.4028236E+38 </li></ol>

<div class="references_section">