ACC: Number Changed Without Warning When Number Is Too Large for Single Data Type (181155)



The information in this article applies to:

  • Microsoft Access 2.0
  • Microsoft Access for Windows 95 7.0
  • Microsoft Access 97

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


  1. Repeat steps 1 and 2 in the "Steps to Reproduce Behavior" section later in this article.
  2. 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


  1. Start Microsoft Access and open any database.
  2. Create the following table named tblTestType:
          Table: tblTestType
          -------------------------
          Field Name: TestSingle
             Data Type: Number
             Field Size: Single
             Format: General Number
    						
  3. 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.
  4. On the View menu, click Datasheet view.
  5. 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.
  6. 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 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:
          -3.4028235E+38
    						

    However, you receive the expected error message when you enter the following number:
          3.4028236E+38
    						

REFERENCES

For more information about data types, search the Help Index for "Single data type" and display the topic "Data Type Summary."

For more information about validation rules, search the Help Index for "validating data, setting up data validation" and display the topic "Restrict or validate data."

Modification Type:MajorLast Reviewed:5/9/2003
Keywords:kbprb KB181155