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



The information in this article applies to:

  • Microsoft Access 2000

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

  1. Follow 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 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

  1. Start Microsoft Access, and then open any database.
  2. Create the following table, and name it 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.
  5. On the Tools menu, click Options, and then click the Keyboard tab. Under Move After Enter, click Don't Move, and 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 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.

REFERENCES

For more information about the single data type, click Microsoft Visual Basic Help on the Help menu, type single data type in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about validation rules, click Microsoft Access Help on the Help menu, type validate or restrict data entry in tables in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:6/28/2004
Keywords:kbprb KB207471