Microsoft KB Archive/199270

= Behavior of query differs for byte data =

Article ID: 199270

Article Last Modified on 4/26/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q199270





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.



Steps to Reproduce Behavior
 Start Microsoft Access.  Create a new table and save it as Table1. Add the following field to the table:   Table: Table1 --  Field name: Field1 Data Type: Number Field size: Byte  Enter the following data in the first three rows:

10, 15, 20

 Close the table.</li> Create an update query based on Table1. To do so, follow these steps: <ol style="list-style-type: lower-alpha;"> In the Database window, click the Query tab, and then click OK.</li> In the New Query box, click Design view, and then click OK.</li> In the Show Table box, select Table1, click Add, and then click Close.</li> Add Field1 to the query grid.</li> On the Query menu, click Update Query.</li> In the Update To row, type [Field1] * 2 .</li></ol> </li> 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: </li></ol>

<div class="references_section">