ElphiusMostafa
ElphiusMostafa

Reputation: 159

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

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

Upvotes: 1

Views: 33

Answers (1)

ElphiusMostafa
ElphiusMostafa

Reputation: 159

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

Upvotes: 1

Related Questions