Combobox: disable or grey out items in the list

ivonsurf123

Registered User.
Local time
Today, 09:46
Joined
Dec 8, 2017
Messages
69
Access 2010, I am trying to disable "Give back" if I select it from the combobox, but is not working now, before it was because I was using a List, but I am using a query now, any help will be appreciate it.

If Me.LeavingGroupProfile.RowSource = "SELECT tbl_LeavingGroupProfile.LeavingGroupID, tbl_LeavingGroupProfile.LeavingGroupName " & _
"FROM tbl_LeavingGroupProfile " & _
"WHERE (((tbl_LeavingGroupProfile.LeavingGroupName) = 'Give Back' " & _
"ORDER BY tbl_LeavingGroupProfile.LeavingGroupName; " Then
Me.Reason_for_Leaving.Enabled = False
Else
Me.Reason_for_Leaving.Enabled = True
End If

:banghead:
 
My understanding (and I'm sure I'll be corrected if I'm wrong) is that you cannot inherently disable rows in a combo box (as in, not allow them as valid selections). In fact, your code above is simply telling the app to compare RowSource to the string you provided, and if the row source (which is, itself, a string) matches the provided string, disable the Reason_For_Leaving control.

If you want to include invalid entries in your list box (which I wouldn't, as a rule, recommend) or include entries that are valid but for which Reason_For_Leaving is NOT valid, then you should include a validation code in the 'On Click' or 'After Update' events that notifies the user that the selection is invalid and/or disables Reason_For_Leaving.

One possible example:

Code:
Me.Reason_for_Leaving.Enabled = (Me.LeavingGroupProfile.Value <> <<ID for 'Give Back'>>)
 
Last edited:
Thank you Frothingslosh, I was able to figure out what I was doing wrong, fix it.
 
As a rule, if you figure out the issue yourself, you should post the answer. That way, if this topic comes up in someone else's search, they'll get the answer right away.
 
Right! Forgot, here it is:

If Me.LeavingGroupProfile.value = 3 Then
Me.Reason_for_Leaving.Enabled = False
Else
Me.Reason_for_Leaving.Enabled = True


Me.Reason_for_Leaving.Requery

End If

need to add the ID instead of the name of the item.
 

Users who are viewing this thread

Back
Top Bottom