yes/no or number

teiben

Registered User.
Local time
Today, 03:07
Joined
Jun 20, 2002
Messages
462
I have rarely used the yes/no field, so I need some assistance. I have a few questions that need to be on a form, the questions are yes/no. I thought I would make the field type a yes or no, but then realized if a no is selected it needs to store a value of 0 and if user selects yes a 1 should be stored, is there a way to do this? or should I just make it a number field type and restrict the values to 0 or 1's?
 
Let it use whatever it wants. You can modify the value in an IIF statement in any query you run against it such as:
YN1: IIF([MyYNfield],1,0)
Which basically says if it is true (yes) substitute a 1, otherwise use zero.
 
Actually, a Yes/No field is what is sometimes called a CAST - or a TYPECAST. It is NOT a native data type.

A Yes/No field is a byte-integer for which FALSE = 0 and TRUE = not 0 (usually -1, which is... not zero). Just like a date is a DOUBLE number of days & fractions thereof from a reference date.

The idea of using a cast is to make it compatible with other systems that cannot or do not want to bit-map all their yes/no fields to the bit level.

As long as Access manages the fields, they will stay consistent. If you attempt to import a numeric field into the byte integer that is cast as yes/no, you might get confusing results. I forget at the moment whether the TRUE value is any non-zero, only bit 0 non-zero, or what. But I know FALSE is true zero, period.
 
if you need to count the number of yes (-1) and nos (0), use the abs function.

Dave
 
sorry, that's only for negative numbers (-1). It actually sums the numbers.
 

Users who are viewing this thread

Back
Top Bottom