Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick Question

Status
Not open for further replies.

Sameal

Programmer
Aug 6, 2001
142
0
0
US
I have a need to keep a binary number saved into one of my Access tables. Does anyone know of a way to specify a field as binary type?
 
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...

 
Can you try creating it as a text field? Terry M. Hoey
 
Why use bit settings? Is there going to be bit manipulation via masking (logical and's/or's)?

Can be achieved with an integer field with values of 1, 2, 3, etc. or text as suggested above.

Dave
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top