Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2003
    Posts
    45

    Unanswered: How to avoid checkbox null value?

    Hi everione!

    Sorry to bother you with such stupid questions BUT:

    How to set the value of an unbound checkbox to NO when opening the Form.
    Right now when I open the Form my checkbox is grey (that's Null value I guess).
    I tried to set Default value to that checkbox to No but when I open the Form my checkbox is still grey/Null.
    I tried also to set Checkbox's value to No with OnChange event of a textbox but it still doesn't work.
    Please help me ...

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    try set the default value to 0 (zero)
    Alternatively on your form load event you could assign a value to the checkbox

    HTH

    EDIT: I believe these are your possible values
    -1 = true
    0 = false
    1 = null
    See the helpfile for more information on checkbox values
    Last edited by gvee; 06-04-07 at 07:15.
    George
    Home | Blog

  3. #3
    Join Date
    Jun 2003
    Posts
    45
    Thank you georgev!

    Everything's OK now (Yes=1, No=0)

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by pivodrinkov
    How to set the value of an unbound checkbox to NO when opening the Form.
    A while since I looked at this but you can specify that a checkbox be tri-state (yes, no, null) or truly boolean (yes, no). In the properties make sure "Triple State" is set to No. I think then you do not need to explicitly set it to false - this is now the default.

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    That does help Poots! I was unaware of this property - it's not often I get to use the delight that is a checkbo - but when I do I will make sure to remember this
    George
    Home | Blog

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by georgev
    That does help Poots! I was unaware of this property - it's not often I get to use the delight that is a checkbo - but when I do I will make sure to remember this
    It is important when you link to something like a SQL Server bit field. They allow nulls. If you link to a bit field containing a null and tri-state turned off expect a dramatic crash
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    So... don't do it
    Set a default value for the textbox of 0 (or 1 - your choice)?
    George
    Home | Blog

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Much the same reason as you might have a null in any other field. Depends on your business requirements\ NULL dogma.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    May 2007
    Posts
    38
    note to op

    out of interest, i think yes is -1, not 1, and no is 0. if you're using access then true and false work better than trying to use numerics anyway. Testing for numeric values might produce errors

  10. #10
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    there is another reason to use the inbuilt vb constants is that they are guaranteed to work. you dont know if or how Microsoft may change the meanings of these values over time, whereas the constant will be able to interpret the values.

    its also easier on the eye when debugging in my view
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •