Checkbox value - Null or True/False?

M

mc

I am trying to build a form with 2 checkboxes. When I use debug to look at
the values of the checkboxes, when I load the form, the value of the
checkboxes are NULL. Then, I checked one of the checkboxes and the value is
-1. So my question is if the checkbox is unchecked, shouldn't the value = 0
instead of being NULL? I am trying to code for the values and was wondering
why some of my code wasn't being executed.
 
D

Douglas J. Steele

Sounds as though you're using an unbound check box. When it's grayed, it's
Null. When it's unchecked but not gray, it's 0. When it's checked, it's -1.
 
M

mc

Doug, thanks for the quick response. It's definitely an unbound check box,
as I am asking the user the option of creating a report, spreadsheet or both.
One last question, is there any coding to see if the check box is grayed?
 
D

Douglas J. Steele

If IsNull(Me.MyCheckbox) Then
' it's gray
End If

Another alternative is to use the Nz function to convert a grayed checkbox
to False:

If Nz(Me.MyCheckbox, 0) Then
' It's checked
Else
' It's either unchecked or gray
End If
 
M

mc

Thank you! Thank you!

Douglas J. Steele said:
If IsNull(Me.MyCheckbox) Then
' it's gray
End If

Another alternative is to use the Nz function to convert a grayed checkbox
to False:

If Nz(Me.MyCheckbox, 0) Then
' It's checked
Else
' It's either unchecked or gray
End If
 

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