I have a list box, and its Muti-Select property is set to Extended. What is the VBA code use to detect if at least one of the item is select from the list ?
If I use the code below to check whether the value of strSQL is null or not, then it would not work if a user, unselect the last item in the list. When the last item in the list is unselected, the event AfterUpdate never gets activated. Since the AfterUpdate events was not activated, then the value strSQL will always contains,the last item that was click (it will never contains a Null value)/
///////////////////////////////////////////////////
Private Sub List_Bus_AfterUpdate()
Dim varItem As Variant
Dim strSQL As String
Dim strSQL_No_Comma_At_End As String
For Each varItem In Me!List_Bus.ItemsSelected
strSQL = strSQL & Me!List_Bus.ItemData(varItem) & ", "
Next varItem
strSQL_No_Comma_At_End = Left$(strSQL, Len(strSQL) - 2)
End Sub
If I use the code below to check whether the value of strSQL is null or not, then it would not work if a user, unselect the last item in the list. When the last item in the list is unselected, the event AfterUpdate never gets activated. Since the AfterUpdate events was not activated, then the value strSQL will always contains,the last item that was click (it will never contains a Null value)/
///////////////////////////////////////////////////
Private Sub List_Bus_AfterUpdate()
Dim varItem As Variant
Dim strSQL As String
Dim strSQL_No_Comma_At_End As String
For Each varItem In Me!List_Bus.ItemsSelected
strSQL = strSQL & Me!List_Bus.ItemData(varItem) & ", "
Next varItem
strSQL_No_Comma_At_End = Left$(strSQL, Len(strSQL) - 2)
End Sub