Can't set value to Null

J

Jazz57

Hi everyone

i have a problem with the use of Null

I have a table that has allready 10 records for testing purposes.
Everything was runnig Ok.

Delete them all to start on the real world and when i tried to add the first
record , received the following message:

"Can't set value to Null when check box property = False"

Could anybody help me with this error

Thanks in advance
 
J

John W. Vinson

Hi everyone

i have a problem with the use of Null

I have a table that has allready 10 records for testing purposes.
Everything was runnig Ok.

Delete them all to start on the real world and when i tried to add the first
record , received the following message:

"Can't set value to Null when check box property = False"

Could anybody help me with this error

Thanks in advance

A Yes/No field can be set to True or to False... but not to Null. That's
simply not a valid value.

Do you have any VBA code setting values in your table? How are you adding
data: through a form, or otherwise?

John W. Vinson [MVP]
 
S

Stuart McCall

John W. Vinson said:
A Yes/No field can be set to True or to False... but not to Null. That's
simply not a valid value.

Ahem. Pedantic correction:

A Yes/No field can be set to True, False or Null when it's bound control's
(checkbox, option button, toggle button) TripleState property is True.
Access displays nulls as a greyed control.
 
M

Marshall Barton

Stuart said:
Ahem. Pedantic correction:

A Yes/No field can be set to True, False or Null when it's bound control's
(checkbox, option button, toggle button) TripleState property is True.
Access displays nulls as a greyed control.

I thought that was only true if the control was bound to an
Integer or Long (any(?) number type) field.
 
S

Stuart McCall

Marshall Barton said:
I thought that was only true if the control was bound to an
Integer or Long (any(?) number type) field.

I've never bound a checkbox to any type other than boolean, so I just ran a
quick test, with checkboxes bound to a boolean and a long, both with
triplestate set to true. When the form (which is bound to a new, untouched
table) opens they're both greyed. However, only the checkbox bound to the
number (long) would allow me to cycle through the 3 states. The boolean
wouldn't allow it.

This leads me to believe that the boolean checkbox is greyed because the
field value is _empty_ rather than null. The documentation for this is (as
usual) hopeless. If this is the case John V, I apologise.
 
S

Stuart McCall

I've never bound a checkbox to any type other than boolean, so I just ran
a quick test, with checkboxes bound to a boolean and a long, both with
triplestate set to true. When the form (which is bound to a new, untouched
table) opens they're both greyed. However, only the checkbox bound to the
number (long) would allow me to cycle through the 3 states. The boolean
wouldn't allow it.

This leads me to believe that the boolean checkbox is greyed because the
field value is _empty_ rather than null. The documentation for this is (as
usual) hopeless. If this is the case John V, I apologise.

I'm beginning to doubt the validity of my last statement. From help:

"Empty Indicates that no beginning value has been assigned to a Variant
variable. An Empty variable is represented as 0 in a numeric context or a
zero-length string ("") in a string context."

So it would seem that the untouched value of a boolean field is null, not
empty.
(I just did another quick check and that is indeed the case)
 
J

Jazz57

Hi

i haven't a Yes/no field in the my table

i have some VBA code sttings in myn table.

to add records i have to click on a button and then is open a
ADODB.connection as a recordset and fullfill the data fields and then click
on other button (Ok button) to save the record.




--
Adriano Santos



"John W. Vinson" escreveu:
 
J

Jazz57

hi Stuart

i don't have a yes/no field on my table neither on my form.

So i really don't know what is happening

--
Adriano Santos



"Stuart McCall" escreveu:
 
T

Tim D

Stuart McCall said:
I'm beginning to doubt the validity of my last statement. From help:

"Empty Indicates that no beginning value has been assigned to a Variant
variable. An Empty variable is represented as 0 in a numeric context or a
zero-length string ("") in a string context."

So it would seem that the untouched value of a boolean field is null, not
empty.
(I just did another quick check and that is indeed the case)

(Another pedeant rides in....) I don't think that is right, the untouched
value of a Boolean field is zero. I made a new table including a Text Field
[Txt] and boolean field [Bool1]. Bool1.DefaultValue is Null. I added 5
records with "a" to "e" in [Txt] and leaving [Bool1] untouched. Querying the
table shows the values for [Bool1] are all zero. Next I added a second
boolean field [Bool2] and queried again. The values for [Bool2] are all zero.

Tim
 
S

Stuart McCall

(Another pedeant rides in....) I don't think that is right, the untouched
value of a Boolean field is zero. I made a new table including a Text
Field
[Txt] and boolean field [Bool1]. Bool1.DefaultValue is Null. I added 5
records with "a" to "e" in [Txt] and leaving [Bool1] untouched. Querying
the
table shows the values for [Bool1] are all zero. Next I added a second
boolean field [Bool2] and queried again. The values for [Bool2] are all
zero.

Tim

I didn't mean to hijack this thread, so I'll post a new one and leave
Adriano & John V to have at it. New thread subject will be 'Boolean Nulls'.
 
J

John W. Vinson

to add records i have to click on a button and then is open a
ADODB.connection as a recordset and fullfill the data fields and then click
on other button (Ok button) to save the record.

Please post your code.

John W. Vinson [MVP]
 

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