473,383 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Boolean vs. Byte datatype

124 100+
In my one table I have a Yes/No field that I need to use in VBA. When I dim the variable which datatype should I use? Byte or boolean? I'd be inclined to use boolean but it's 2 bytes whereas byte is 1. And I've found that either one works. That is, I could have bytVariable = -1 or blnVariable = True. Is there a real difference? Does it matter?
May 17 '10 #1

✓ answered by Jim Doherty

@bullfrog83
Not really. Provided you are happy. 1 and 0 is as good true and false in my book. In fact ..... if and should you ever upscale to SQL server you will see that Access treats true and false values as null (if not instantiated to one or the other (true or false) it has a three logic state which breaks the big daddy database 'bit' datatypes which are bit data 1 and 0. Not insurmountable but a needless scalability consideration in my view

5 3975
Jim Doherty
897 Expert 512MB
@bullfrog83
Not really. Provided you are happy. 1 and 0 is as good true and false in my book. In fact ..... if and should you ever upscale to SQL server you will see that Access treats true and false values as null (if not instantiated to one or the other (true or false) it has a three logic state which breaks the big daddy database 'bit' datatypes which are bit data 1 and 0. Not insurmountable but a needless scalability consideration in my view
May 17 '10 #2
NeoPa
32,556 Expert Mod 16PB
I recommend using Boolean fields and the True value. -1 (== True) is a 1 in every bit. It is not quite the same as non-zero. Boolean expressions return True and False (== 0), not 1 and 0.

The size consideration is not as important today as it was considered in earlier years. In fact, due to the importance of aligning variables on 32-bit boundaries anyway, Byte variables often (There are exceptions of course) take up 4 bytes anyway.
May 17 '10 #3
bullfrog83
124 100+
@Jim Doherty
I do plan on moving my Access db to SQL server. So, if I understood you correctly, I should use byte instead of boolean?
May 17 '10 #4
Jim Doherty
897 Expert 512MB
@bullfrog83
Not necessarily.....I just mentioned that Yes/No fields in Access have a three logic state namely true false and null. Practically speaking it is the same as this....if you click the tick it is true if you click the tick and click it off again it is false. ...but if you never click it all and have NO default it will be null in the table row. Now what happens when you try and upload that to SQL Server as the natural equivalent which maps the 0 or 1 true/false BIT field in SQL Server it makes the server cough and reject your data upload. The nulls is a known problem on conversion. A quick search on the web will show you all sorts of discussions about this, It is not grave so dont let it concern your choice too much.

Don,t let this put you off, Its not insurmountable, its not major, it is just burdensome sometimes to go through a very sophisticated large db hunting out the upgrade problems thats all...If you want to use boolean then fine, go ahead and use it, just be aware about the providing the default in your table. If you do that then you will have no issue.
May 17 '10 #5
bullfrog83
124 100+
@Jim Doherty
Ok, I understand what you were saying now. I always specify a default value for my Yes/No fields so I'm good. Thanks!
May 17 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dan | last post by:
Hello. I have recently tried upgrading the MySql connector for my servlet from 2.0.4 to 3.0.9. I have found a minor limitation in 2.0.4 and was hoping that 3.0.9 would fix it. However, now I...
14
by: Elias Farah | last post by:
Hi All, What are people's experience in timing Query Performance? I have tried in vain, but get many unpredictable results, with execution proceeding in the background and problems of timing...
9
by: rahul | last post by:
Hi!, I have a java program that receives data via sockets from a C program. The java program has to recieve the data in byte format. I need to send character arrays from the C side after...
4
by: chris chan | last post by:
Is there any way to compare two byte by XOR in a fast way and return the number of bits is equal . e.g. b1 = 11100011 b2 = 01010010 after XOR compare will return 4 bit is equal
8
by: Metro Sauper | last post by:
Why is the default text representation for booleans in C# 'True' and 'False' whereas in xml it is 'true' and 'false'? It seems like it would make sense to have them both the same. Metro T....
3
by: Ken Durden | last post by:
Is there any constant in the .NET API Framework indicating the # of bits per byte (or int, or anything else)? Kinda like std::numeric_limits for C#? I know they're all constant (unlike C/C++) I...
2
by: aengus | last post by:
Hi, I am looking to find out how to deal with the BYTE datatype in VC, as used below: This struct is part of the API for a Garmin GPS unit: typedef struct { unsigned char mPacketType; ...
8
by: Vinod | last post by:
Hi, I have a stored procedure which expects a varbinary datatype. How can i pass a varbinary datatype from asp.net directly to the stored procedure. I tried using the Convert function in Sql...
1
by: keithb | last post by:
The following code sets a DataTable column DataType to "String" column.DataType = System.Type.GetType("System.String"); What is the corresponding statement when the data type is boolean? I...
2
by: ikramshah | last post by:
how to make a 16 byte data type in C++??
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.