Check Box Disabled unless specific item selected in combo box

Johnny Drama

In need of beer...
Local time
Today, 08:34
Joined
Dec 12, 2008
Messages
211
Hi all,

I'm trying to keep a check box disabled until a specific item in a combo box is selected from the choices, i.e, Item number 2 out of the 6 possible choices.

I know the after update event should trigger the enabling of the check box, but I'm not sure how to go about doing that.

Any pointers?

Thanks in advance!
 
You'll have to replace ComboboxName and CheckboxName with your actual names:

Code:
Private Sub ComboboxName_AfterUpdate()
 If Me.ComboboxName = "2nd Item" Then
  Me.CheckboxName.Enabled = True
 Else
  Me.CheckboxName.Enabled = False
  Me.CheckboxName = Null
 End If
End Sub

Code:
Private Sub Form_Current()
If Me.ComboboxName = "2nd Item" Then
  Me.CheckboxName.Enabled = True
 Else
  Me.CheckboxName.Enabled = False
 End If
End Sub

Linq ;0)>
 
If your combo box is storing the IDs of a reference table, would it be good practice to have the combo look for ID 2, rather than the text?
 
Nope. Using the Value of the Combobox works just fine! And the code has the advantage of working for any type of Control.

Linq ;0)>
 
Will this code work in Access 2010. I copied the code just as you have written it changed the name of the cbo box and the checkbox, but the checkbox will not become enabled.
 
I was able to get it to work. I added the column count.
Private Sub Form_Current()
If Me.ComboboxName.column (1) = "2nd Item" Then
Me.CheckboxName.Enabled = True
Else
Me.CheckboxName.Enabled = False
End If
End Sub
 
you can simplify your code

Code:
 Me.CheckboxName.Enabled =Me.ComboboxName.column (1) = "2nd Item"
 
CL_London, the actual goal was to have the "Notes" control visible if any selection is made in (cboHospClearReason), so I used the following code which is working.

Code:
Private Sub cboHospClearReason_AfterUpdate ()
       If IsNUll (Me.cboHospClearReason) Then
       Me.chkReturned.Enabled = False
       Me.chkReturned = Null
    Else
       Me.chkReturned.Enabled = Enabled
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom