assigning null value to the Yes/No field

D

dev guy

hi

I want to assign null value to Yes/No field. So that the value of the field
is neither YES nor NO. Is this possible? The field properties show that
there is a property called "Allow Null". I have set it to TRUE. But this
does not help.

I thereafter try to access this table from VB.NET and try to read the value
or insert a record with this field value as NULL. But when I read the record
as DBBoolean, I always get value as FALSE.

Can somebody throw some light on the same?

warm regards
Haresh Gujarathi
 
A

Allen Browne

Unfortunately, the Yes/No field type in Access (JET) cannot handle Null.

Instead, use a Number field.
Use -1 for True, and 0 for False, and you will be able to enter a Null.
 
J

Jamie Collins

Allen Browne said:
Instead, use a Number field.
Use -1 for True, and 0 for False, and you will be able to enter a Null.

The OP additionally needs a CHECK constraint e.g.

ALTER TABLE MyTable ADD
CONSTRAINT ch_mytable__boolval
CHECK (MyIntCol IN (-1,0))
;

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top