Number data type of size Byte

When considering the size of a number type, you should select the smallest size that will accommodate your data.  This provides some validation.  If you know that you need only integers and don't require something larger than 32,767 or less than –32,768, then Integer size would ensure you don't enter values outside that range.  There is more information on this in this MS Knowledge Base article.

However, you should be cautious in expecting the Byte size to behave correctly.  A Byte size is supposed to store integers from 0 to 255.  However, you will find that in the following cases, a value outside that range can be entered.  Instead of giving an error, or a warning, it silently puts in a different value than you entered.

An Append query: INSERT INTO Test (ByteField) SELECT 456 AS Expr1 - This will silently append 200 (456-256) to the Field
An unbound form - Opening a recordset on the table and updating or adding records (or by using a SQL statement in code).

Note this doesn't happen if you enter values directly into the table, a select query based on the table, or a form bound to the table.  In these cases an error is displayed.
 

 
     

Home | Access Tips | Clients | Links

Copyright 2004 - Joan Wild