I want to select from a table records that have a particular bit hold in a
field of type integer. Is there a way to do this in a simple way ?
Thanks for any help
The easiest way to do this is to write a "BitwiseAnd" function:
Function BitwiseAnd(x As Long, y As Long) As Long
BitWiseAnd = x And y
End Function
then use this in your query, e.g.:
Select * from MyTable Where BitwiseAnd(MyField, 4)>0
to select records with bit 2 of MyField set.
----
Simon Lewis
"mchd" <mc...@wanadoo.fr> wrote in message
news:OLWC943xCHA.2596@TK2MSFTNGP12...
>I want to select from a table records that have a particular bit hold in a
>field of type integer. Is there a way to do this in a simple way ?
I usually use a function like Simon suggested, but in some
situations that's been slow.
**If you only need to test a single bit** and it's not the
high (sign) bit, an alternative is to use an expression in
the query:
(field \ (2 ^ bitnum)) Mod 2 <> 0
--
Marsh
MVP [MS Access]