2

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().

9
  • @HansUp no, expecting CRShtnvsp_AfterUpdate() to run after checking CRShtnvsp. Commented Feb 2, 2023 at 18:54
  • FYI - not your issue but you could replace the If Else with just CRShtn_vaso_phen.Enabled = CRShtnvsp Commented Feb 2, 2023 at 18:58
  • @TimWilliams thanks! I think someone else mentioned that to me in the past, but forgot to make the udpates. Good reminder! Commented Feb 2, 2023 at 19:00
  • @HansUp I've never tried a break point before, but will give it a shot. Will update. Commented Feb 2, 2023 at 19:01
  • 1
    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 should be enough to remind Access it exists. Commented Feb 2, 2023 at 19:23

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

7 Comments

like this? Private Sub CRShtn_AfterUpdate() If CRShtn = True Then CRShtnvsp.Enabled = True CRShtn_vaso_phen.Enabled = True Else CRShtnvsp.Enabled = False CRShtn_vaso_phen.Enabled = False End if End Sub
Yes! This should enable them both now like desired.
Update: tried that and CRShtn_vaso_phen now enables when CRShtn is checked. But that's not the sequence of events I'm hoping for. I'd like CRShtn_vaso_phen to enable only after CRShtnvsp has been checked. But CRShtnvsp isn't enabled unless CRShtn is checked.
Add it in a separate if statement. Just below the other one. Private Sub CRShtn_AfterUpdate() If CRShtn = True Then CRShtnvsp.Enabled = True Else CRShtnvsp.Enabled = False End if If CRShtnvsp = True Then CRShtn_vaso_phen.Enabled = True Else CRShtn_vaso_phen.Enabled = False End if End Sub
yeah I've tried that as well, and no luck
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.