ACC2000: Behavior of Query Differs for Byte Data

ID: Q199270


The information in this article applies to:
  • Microsoft Access 2000

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

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


SYMPTOMS

When you create an update query that calculates values for a Numeric field whose FieldSize property is set to Byte, you may not get the results that you expect when the calculated value in the field is larger than what the Byte size data type can hold. If this happens, the query updates the value in the field to the calculated value minus 256.


CAUSE

The Byte data type is used to store small, positive integers ranging from 0 to 255.


RESOLUTION

Use a different field size for your calculated field if you are going to be creating calculations that exceed 255.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Microsoft Access.


  2. Create a new table and save it as Table1. Add the following field to the table:


  3. 
       Table: Table1
       ------------------
       Field name: Field1
       
       Data Type: Number
       Field size: Byte 
  4. Enter the following data in the first three rows:


  5. 10, 15, 20
  6. Close the table.


  7. Create an update query based on Table1. To do so, follow these steps:


    1. In the Database window, click the Query tab, and then click OK.


    2. In the New Query box, click Design view, and then click OK.


    3. In the Show Table box, select Table1, click Add, and then click Close.


    4. Add Field1 to the query grid.


    5. On the Query menu, click Update Query.


    6. In the Update To row, type [Field1] * 2.


  8. Run the query four times. Click Yes to each confirmation message.

    Note that when the value that should be returned is greater than the Byte data type size limitation of 255, an incorrect value is returned to the field. In the above example, the values that are returned each time that you run the query are as follows:


  9. Query Returned Values
    One 20, 30, 40
    Two 40, 60, 80
    Three 80, 120, 160
    Four 160, 240, 64


REFERENCES

For more information about field sizes, click Microsoft Access Help on the Help menu, type "fields, size" in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Additional query words: prb

Keywords : kbusage kbdta QryUpdat QryProp
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: May 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.