Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2004
    Location
    Ga
    Posts
    16

    Unanswered: Enable/Disable Checkbox

    I have a tab on my database with 5 checkbox options. All the checkbox on the page are enabled. However, I need to disable one of the boxes whenever a particular box is checked ie

    "When FMLA is checked, the Occurence checkbox is disabled" On the other hand, checking Occurence does not affect the FMLA.

    All inputs will be appreciated.

  2. #2
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Re: Enable/Disable Checkbox

    Hi Roman,

    How did you set up your check boxes? Are they all based on just one field each in your table? Or did you create just one field and simple place check boxes on the form? That's a start...

    Bud

  3. #3
    Join Date
    Feb 2004
    Location
    Ga
    Posts
    16
    The checkboxes are based on different fields. For example, In addition to the FMLA and Occurence checkbox, I also have have a LOA, and 3 in 12 checkbox. They're all fields in the AbsenceTbl.

  4. #4
    Join Date
    Nov 2003
    Location
    San Francisco, CA USA
    Posts
    59
    I'd do something like this (syntax could be way off-base but you'll get the gist of it)

    Dim FMLAOn As Boolean

    FMLAOn = Me.[FMLA] '(or Me.[FMLA].Value) I am rusty so I have to try both and see which is right.

    Me.[Occurrence].Enabled = FMLAOn + 1

    I am sure there most be a more elegant way to do this. But I think this works. If FMLA is checked (-1) then adding 1 changes the boolean value to false. If it's not (0) then adding 1 makes the result non-0 and again sets the boolean value to true. (Isn't that right, any non-0 number evaluates to true in Access?)

    If I'm getting my languages confused, you'd have to substitute an expression to invert the value of OccurrenceOn before assigning it to the Enabled property of [Occurrence]. There's probably a function to do that too.

    You could always do this:

    If Me.[FMLA] Then
    Me.[Occurrence].Enabled = 0
    Else
    Me.[Occurrence].Enabled = -1
    End If

    Attach this or similar code to the appropriate change event in the FMLA field and you're set.

    Magee

    (Changed the variable name to make more sense.)
    Last edited by mageem; 02-04-04 at 17:04.

  5. #5
    Join Date
    Feb 2004
    Location
    Ga
    Posts
    16
    Thank you Mageem. I aapreciate you help.

  6. #6
    Join Date
    Nov 2003
    Location
    San Francisco, CA USA
    Posts
    59
    No problem! Sorry I can't promise you my syntax is correct. I'm on a Mac right now so I can't test it.

    Magee

    BTW, I figured out how to deal with the "does Access recognize non-0 as true" problem.

    Change the code I wrote from:

    Me.[Occurrence].Enabled = FMLAOn + 1

    to:

    Me.[Occurrence].Enabled = (FMLAOn + 1) * -1

    That evaluates to -1 if FMLAOn is 0 and 0 if FMLAOn is -1.

    Whew! I knew there was a way that I had done that before.

Posting Permissions

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