Results 1 to 6 of 6

Thread: check not null

  1. #1
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98

    Unanswered: check not null

    Hi,

    How can I make sure that at least one of the four checkboxes on my form is checked? I don't want to be able to save a record that has not been saved.

    thanks,
    charlotte

  2. #2
    Join Date
    Jun 2004
    Posts
    55
    This should be what you're looking for

    If (checkboxname) = False then


    and put whatever coding you want after that.

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    i have never tried this, but maybe it works:

    if (chkbox1 + chkbox2 + chkbox3 + chkbox4) = 0 then ' failed

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by izyrider
    i have never tried this, but maybe it works:

    if (chkbox1 + chkbox2 + chkbox3 + chkbox4) = 0 then ' failed

    izy

    That's a good idea, except if the default value for the checkbox is null...

    Anything + null = null. Therefore, you could evaluate the above for NULL instead of 0:

    if IsNull(chkbox1 + chkbox2 + chkbox3 + chkbox4) then 'failed

    You may have to do both evaluations just to be safe:

    if IsNull(chkbox1 + chkbox2 + chkbox3 + chkbox4) OR (chkbox1 + chkbox2 + chkbox3 + chkbox4) = 0 Then
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    hi Teddy,

    well spotted!
    here is a refinement:

    if (nz(cbx1, 0) + nz(cbx2, 0) + nz(cbx3, 0) + nz(cbx4,0)) = 0 then 'failed

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by izyrider
    hi Teddy,

    well spotted!
    here is a refinement:

    if (nz(cbx1, 0) + nz(cbx2, 0) + nz(cbx3, 0) + nz(cbx4,0)) = 0 then 'failed

    izy

    Refined again!


    if nz((cbx1 + cbx2 + cbx3 + cbx4), 0) = 0 then 'failed

    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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