Home > front end >  Can I use VBA to disable a check box with a condition that is based on a text in a combo box?
Can I use VBA to disable a check box with a condition that is based on a text in a combo box?

Time:01-28

I have a combo box cpm and a checkbox cpm_meth_culture. If cpm is "No", then I'd like to disable the checkbox cpm_meth_culture. Is this possible?

I've tried the following with visual basic, but it's not doing anything:

Private Sub cpm_AfterUpdate()
    If Me.cpm = "No" Then
        Me.cpm_meth_culture.Enabled = False
    Else
        Me.cpm_meth_culture.Enabled = True
    End If
End Sub

CodePudding user response:

Figured out the issue. The cpm combo box is in bit format with yes/no options for row source. Since it's stored as a bit, then the code has to be:

Private Sub cpm_AfterUpdate()
    If Me.cpm = 0 Then
        Me.cpm_meth_culture.Enabled = False
    Else
        Me.cpm_meth_culture.Enabled = True
    End If
End Sub
  • Related