How to fix "can not enable after disable" message?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gina farrow
    New Member
    • Jan 2011
    • 23

    How to fix "can not enable after disable" message?

    When I enter the code below I get a message"can not enable after disable." Access 2010 it works,however in access 2007 it doesnt work.

    Private Sub CheckBox2_Click ()
    If CheckBox2 = True Then
    CheckBox2.Enabl ed = False
    End If
    End Sub
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    You cannot Disable a Control when it has the Focus. To get around this, in the AfterUpdate() Event of the Control, shift the Focus to another Control on the Form, then disable the Control, as in:
    Code:
    Private Sub CheckBox2_AfterUpdate()
      If CheckBox2 = True Then
        Me![txtDate].SetFocus              'Shift Focus to Date Text Box
          CheckBox2.Enabled = False        'Now, Disable CheckBox2
      End If
    End Sub

    Comment

    • gina farrow
      New Member
      • Jan 2011
      • 23

      #3
      Thank you it works!

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        You are quite welcome.

        Comment

        Working...