How to check if Boolean variable has been set

BiigJiim

Registered User.
Local time
Today, 13:22
Joined
Jun 7, 2012
Messages
114
Hi,

I have an Access 2010 db which has a load of global variables of type Boolean. The values are different for each machine the database is stored on, so I have a linked table to a separate Access mdb. On startup the database opens the linked table and assigns values to each variable.

However I need to differentiate between a valuable value of False and the variable having not been set. As boolean variables default to False, this is a problem. One option is to use data type Variant, but I know this is not efficient. I am considering using data type Byte instead of Boolean, with 1 as False and 2 as True, but can someone tell me if this is the most efficient way and what is the commonly established way of dealing with this?

Many thanks,
Jim
 
Thanks Paul. I just had the feeling I was missing something stupid. Thanks also for the link to Allen Browne's article - anyone else following this thread, it is worth a read - I had never realised the severe implications for outer join queries!
 
if a two state variable is no good, then you are probably better using a number.

do you really need a third state though? I appreciate the technical difference but do you really need a setting for neither true or false?
 
if a two state variable is no good, then you are probably better using a number.

do you really need a third state though? I appreciate the technical difference but do you really need a setting for neither true or false?

Hi Dave,

Unfortunately I think I do. One of the variables stores whether a local piece of hardware (which can be easily disconnected) has been detected, and another stores whether or not the user has selected for the program to communicate with an external system, which may or may not be online. So in both cases the system needs to act differently when the variable is set to false, to how it does when the variable has not been set.

Hope this makes sense!
Jim
 
Maybe

A) the option for external communication -the second case you mention - is either true, or not true , so I think a boolean is fine for that.

B) the problem with the external equipment papers to be a slightly different issue - but again it seems to me a normal boolean will handle it, except that you may need to explicitly check whether the connection remains active when required.
 
Maybe

A) the option for external communication -the second case you mention - is either true, or not true , so I think a boolean is fine for that.

B) the problem with the external equipment papers to be a slightly different issue - but again it seems to me a normal boolean will handle it, except that you may need to explicitly check whether the connection remains active when required.

Hi Dave,

Unfortunately, in both cases, there is a big difference between the variable not being set (in which case the user needs to be made aware and prompted for some action) and the variable set as NO (in which case he/she doesn't.)

It's also worth reading the link above, posted by PBaldy, which details how a null boolean in an outer join query causes Access to crash and burn completely. (Allen Browne's conclusion - NEVER ever use Yes/No fields in a JET database.)

http://allenbrowne.com/NoYesNo.html

Anyway, looks like I am on the right track - thanks all!

Jim
 

Users who are viewing this thread

Back
Top Bottom