Results 1 to 13 of 13
  1. #1
    Join Date
    Apr 2012
    Posts
    31

    Unanswered: Tick box/check box

    Hi friends.

    On my form in MSACCESS 2010 I have a few check boxes.

    What I want to do is when I select the check box called: ‘No fault Found’ I want all of the other check boxes ‘fault 1’, ‘fault 2’ etc. to be greyed out (as they will not be applicable). Any help would be fantastic.

    BR

    Ed.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Use the AfterUpdate event of the ‘No fault Found’ checkbox to set the Enabled property of the other checkbox controls ( ‘fault 1’, ‘fault 2’ etc.) to False:
    Code:
    Private Sub Check_NoFaultFound_AfterUpdate()
    
        Dim booEnabled As Boolean
    
        booEnabled = Not Me.Check_NoFaultFound.Value 
        Me.Check_Fault1.Enabled = booEnabled 
        Me.Check_Fault2.Enabled = booEnabled 
    
    ' etc...
    
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Apr 2012
    Posts
    31
    Thanks for your quick reply, but i cant seem to get this to work. I have copied the code in but when i go back into form view and click no fault found I get an 'unexpected end sub' message' and the first line of the code is highlighted yellow? Any thoughts?

    Thanks again!

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Please post the code.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  5. #5
    Join Date
    Apr 2012
    Posts
    31
    Hi so here is the code. This is the Afterupdate from my 'no fault found' tick box.
    Ideally i would like to be able to check this box and all of the other check boxes on my form 'fault 1, fault 2 fault 3 etc would be greyed so they can not be selected because no fault has been found. Hope this makes sense!

    Private Sub No_Faults_Found_AfterUpdate()
    Dim booEnabled As Boolean

    booEnabled = NotMeCheck.nofaultsfound.Value
    Me.Check_fault1.Enabled = booEnabled
    Me.Check_fault2.Enabled = booEnabled
    Me.check_fault3.Enabled = booEnabled

    End Sub

  6. #6
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Here is your problem:
    booEnabled = NotMeCheck.nofaultsfound.Value
    ought to be
    Code:
    booEnabled = NotMeCheck.No_Faults_Found.Value
    This assumes that the form is called NotMeCheck.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. In the code I posted, the line was (with a space between Not and Me):
    Code:
    booEnabled = Not Me.Check_NoFaultFound.Value
    2. The code I posted supposed that the checkbox controls are named Check_NoFaultFound, Check_Fault1, Check_Fault2, etc. You must adapt it to the real names of the controls in your form.
    Have a nice day!

  8. #8
    Join Date
    Apr 2012
    Posts
    31
    All working now - thanks for your help. I was interpreting 'check_' as an actual database command. Silly me. Thanks again.

  9. #9
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

  10. #10
    Join Date
    Apr 2012
    Posts
    31
    Sorry to bother you again with this I have realised that when I select 'no fault found' everything greys out as expected, but when click the navigation button on the form to start a new form, the current form disappears behind my main switchboard form. Any thoughts on this?

  11. #11
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If you open the form as Modal, it will keep the focus until it's closed.
    Have a nice day!

  12. #12
    Join Date
    Apr 2012
    Posts
    31
    Thanks again. [hands over virtual beer]

  13. #13
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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