ElphiusMostafa
ElphiusMostafa

Reputation: 159

Checkbox to enable/disable other checkboxes in form

I have a checkbox CRShtnvsp and if checked, I have VBA code to enable additional checkboxes. This checkbox is enabled/disabled via another checkbox CRShtn. That sequence works.

I want CRShtnvsp to enable additional checkboxes.

VBA for both CRShtnvsp and CRShtn below.

This code works:

Private Sub CRShtn_AfterUpdate()
    If CRShtn = True Then
        CRShtnvsp.Enabled = True
    Else
        CRShtnvsp.Enabled = False
    End if
End Sub

This code does not work:

Private Sub CRShtnvsp_AfterUpdate()
     If CRShtnvsp = True Then
          CRShtn_vaso_phen.Enabled = True
     Else
         CRShtn_vaso_phen.Enabled = False
     End if
End Sub

All checkboxes are set to Enabled = No in the property sheet so they are disabled until prior checkboxes or comboboxes on my form are changed using AfterUpdate() or Form_Current().

Upvotes: 2

Views: 302

Answers (2)

HansUp
HansUp

Reputation: 97101

Sometimes Access seems to lose track of an event procedure. I don't know why that happens, but if that's your situation, you can remind Access the procedure exists.

Go to the Event tab on the property sheet for your CRShtnvsp checkbox. In the "After Update" property box, make sure "[Event Procedure]" is selected and then press the button labelled with 3 dots. You should be at your existing procedure. And I think that should be enough to remind Access it exists.

Upvotes: 2

user17303987
user17303987

Reputation: 25

CRShtnvsp is not updating as it's not being used - I would try adding the code for enabling the next button under the original button you're using and see if that works. To clarify: Add the code for enabling CRShtn_vaso_phen under the CRShtn_AfterUpdate sub.

Upvotes: 0

Related Questions