CheckBox returning a Null value - is it a common thing?

M

Morris

Hi all,

I know a checkbox is supposed to return a True (-1) value when in
selected state or False (0) value when in unselected state. And that
works fine.

The problem is that right after opening the form the CheckBox is
unselected by default but it's got no value - it returns Null and
isnull(me.check15) returns True.

Is this a correct behaviour? Should I have a OnLoad event which makes
all the checkboxes False?

Thanks for help
Morris
 
S

Stefan Hoffmann

hi Morris,
Is this a correct behaviour? Should I have a OnLoad event which makes
all the checkboxes False?
You may set the DefaultValue property to True or False depending on your
logic behind it.


mfG
--> stefan <--
 
D

Dirk Goldgar

Morris said:
Hi all,

I know a checkbox is supposed to return a True (-1) value when in
selected state or False (0) value when in unselected state. And that
works fine.

The problem is that right after opening the form the CheckBox is
unselected by default but it's got no value - it returns Null and
isnull(me.check15) returns True.

Is this a correct behaviour? Should I have a OnLoad event which makes
all the checkboxes False?


If the check box is unbound, then it will have a Null value until you set
it, unless you've given it a default value. If it's bound to a boolean
(yes/no) field, it can't have a Null value unless that field is on the
unmatched side of an outer join, because the Jet database engine can't store
Null in a boolean field. If it's bound to some other type of field, an
Integer field for example, then the field could have a Null value and the
check box will reflect it.
 
M

Morris

If the check box is unbound, then it will have a Null value until you set
it, unless you've given it a default value. If it's bound to a boolean
(yes/no) field, it can't have a Null value unless that field is on the
unmatched side of an outer join, because the Jet database engine can't store
Null in a boolean field. If it's bound to some other type of field, an
Integer field for example, then the field could have a Null value and the
check box will reflect it.

Thanks both of you for an exhausting explanation.

At first I assumed there must be a 'DefaultValue' setting for this
control but to my surprise there wasn't any. That's why I posted this
question here. Obviously as you know after I clicked the checkbox, by
default both checkbox and corresponding lable were selected, giving me
properties of a label. Now I've set a DefaultValue = False (as it's
unbound) and everything works great,

Thanks once again!
Morris
 

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