Checkbox value - Null or True/False?

  • Thread starter Thread starter mc
  • Start date Start date
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.
 
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.
 
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?
 
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
 
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
 
Back
Top