What is the source of the binary number? Imported from a text file, a SQL Server query, user input in a form?
As far as storing the value, the field in your table just needs to be designed as a Number data type with a field size (Byte, Integer, etc.) that is sufficiently large to accomodate your largest expected value.
Do you want the number to appear as a binary format (base two - ones and zeros) when you display it on a form or report?
I want to use the field as a logical flag with several conditions. 8-bits means I can work 8 flags into one field which is all I need. Am I going to have to make the select statements work off the normal number version of my binary? Like...
-BINARY- -#- -Description of Flag-
10000000 - 1 - Record has Material Added
01000000 - 2 - Record has Tooling Added
00100000 - 4 - Record has Outsourced Operations Attached
00010000 - 8 - Etc...Etc...
I'm going to attempt to use the 'byte' data type setting.
And yes, I wanted to be able to say '01000000' AND '10000000' which would produce '11000000' which then my program would know that both flags are turned on.
Also by using binary I do not waste tons of space with each record for this flag that is unneeded. With a string, every character is a byte of its own. Using binary I can use 1 byte for 8 flags.
I think I'm going to try to have it check for the numeric equivalents to the binary code, ie: 01000000 = 2
if <blah> = 2 then 'same as 01000000
do this
Only thing about doing it this way is I got to make case statements for all cases inbetween like 11000000 = 3 and 11100000 = 7 but I'll make do I guess.
>Also by using binary I do not waste tons of space with each record for this flag that is unneeded
The easiest way is to use an Yes/No (boolean) data type field for each flag. Otherwise, you will spend too much time writing and testing conversion routines. Neufarth's suggestion of an integer field is also a good solution, especially if you define some global predefined constants.
If you are worried about saving space, you are developing in the wrong environment. Access is meant to be to provide a consistent and familiar user interface and to be convenient and fast for developers. It is not meant to optimize the use of resources at the bit level.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.