Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2011
    Posts
    413

    Unanswered: If One is True Then The Other is False

    I have two bound controls on my form, both with a yes/no check box. One is Contacted and the other Need To Contact. If Contacted is checked then I need Need to Contact to be Unchecked. In other words, can't have both checked at the same time. The girl is either contacted or not! Upon checking one of them the other one needs to be unchecked.

    Thanks,

  2. #2
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    My first question is why do you want two checkboxes if they can't both be checked? It's the inherit purpose of a checkbox that if it's not checked, it's unchecked. In other words, if you have a contacted checkbox and it's unchecked, then that girl needs to be contacted.

    But, if you have a reason for this try creating an option group and style them as checkboxes. The group will automatically handle what you are looking for.

    Steve

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    While a Checkbox does, of course, come with the understanding that something is True if it's ticked and not True if it's not ticked, things have to be made more clear to some users than to others, and an Option Group, as suggested by Steve, does that well! If you haven't created one of these before, here's a quick little step-by-step:

    In Form Design View

    Place an Option Group Control on Form (the icon looks like a single File Folder with 'xyz' across the top)[/B]

    When the Wizard comes up enter your Labels

    • Need to Contact
    • Contacted

    Click on <Next>

    Select a Default if desired (I wouldn't)

    Click on <Next>

    You’ll see the Values that will be assigned for each Label:

    • Need to Contact: 1
    • Contacted: 2

    Click on <Next>

    Select from Option Buttons, Checkboxes or Toggle Switches

    Click on <Next>

    Enter a Caption to appear on your Option Group

    Hit <Finished>

    Access will name the OG Control using something like FrameX with the 'X' being a number

    With the Frame selected
    • Go to Properties – Other and in the Name Property replace FrameX with something more appropriate, such as ogContacts
    • Go to the Data Tab
    • In the Control Source Property use the DropDown to select the Field where the data is to be stored in the underlying Table
    When referring to the Field, such as to test its Value to decide on some behavior, you’d use something like

    Code:
    Private Sub ogContacts_AfterUpdate()
     
     Select Case Me.ogContacts
      
      Case 1
       
       'What to do if need to contact is true
       
      Case 2
       
       'What to do if need to contact is not true
       
      End Select
      
    End Sub


    As Steve also said, Access will now handle your requirement, only allowing one of the Checkboxes to be ticked at a time.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Quote Originally Posted by Missinglinq View Post
    Click on <Next>

    Select a Default if desired (I wouldn't)
    If this is intended to make it clearer to a certain set of users that two options are available, Contacted and Need to Contact, then for a new record a default of Need to Contact might be clearer.

    The danger with the default value is you have the potential of saving a record with inaccurate information. Assume that you are creating a new record for a girl who was already contacted and Need to Contact is checked by default. If you don't remember to change this you just created a record with incorrect data.

    If your business process is such that you are always entering a new record before they are contacted, then having a default checked can be less confusing than two checkboxes that appear to be disabled. However, if it is possible to enter a new record for a girl who is already contacted, I would leave them without a default as previously suggested. I just don't like the way they are initially displayed if a default is not chosen and I avoid it when I can.

    You just have to be aware of how the system will be used and then decide which method is clearer to the users.

    Steve

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by sps View Post

    ...for a new record a default of Need to Contact might be clearer.
    True, but in addition to your warning about Saving the Record with incorrect data, I've found that users, when basing an action on the Value of a Control, usually use the AfterUpdate event of that Control, and when populated by a Default Value, this event never pops and the action is not carried out! This can be worked around, of course, by placing a 'Call' to the Sub, but it is more complicated for newbies to try to understand.

    Quote Originally Posted by sps View Post

    ...You just have to be aware of how the system will be used and then decide which method is clearer to the users.
    Also true; it all really comes down to how savvy your end-users are!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Quote Originally Posted by Missinglinq View Post
    I've found that users, when basing an action on the Value of a Control, usually use the AfterUpdate event of that Control, and when populated by a Default Value, this event never pops and the action is not carried out!
    I tend to be the sole developer on these systems so I hadn't thought of that, but I can definitely see the value of keeping it in mind. Thanks for the insight.

    Steve

  7. #7
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Insights 'R Us!

    Seriously, you really do have to keep the big picture in mind, especially when advising newbies, as most of our work here involves.

    And trolling these sites is especially helpful, I've found, when you're a 'lone-ranger' developer! I wrote programs for five years prior to being on-line and connecting to other code-heads, and went ten years before actually meeting one, face-to-face! It's always nice to have access to other peoples' approaches to a problem, as well as their experiences with end-users!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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