I have a multi select list box filled with subject titles. I am trying to do 2 things but getting nowhere.
If one row of the list box is selected, I want to select all records that are applicable. When more than one row is selected, I am trying to identify records that have both selections being applicable to them, and those records that do not have both then drop out of mt selected records list.
I just seem to continually build my list, and show duplications. Cannot work out how I build in an AND statement when not knowing what/number of items will be selected in the list.
If one row of the list box is selected, I want to select all records that are applicable. When more than one row is selected, I am trying to identify records that have both selections being applicable to them, and those records that do not have both then drop out of mt selected records list.
I just seem to continually build my list, and show duplications. Cannot work out how I build in an AND statement when not knowing what/number of items will be selected in the list.
Code:
Dim i As Variant
Dim Criteria As String, Criteria2 As String, MySql As String
Criteria = "": Criteria2 = ""
For Each i In Me![List947].ItemsSelected
Criteria2 = Criteria2 & "," & Me.List947.Column(0, i)
Next i
MySql = "SELECT MAIN.ID1, JUNCTION1.KeywordID FROM KEYWORD INNER JOIN "
MySql = MySql & "(MAIN INNER JOIN JUNCTION1 ON MAIN.ID1 = JUNCTION1.ID1) ON KEYWORD.ID2 = JUNCTION1.ID2"
MySql = MySql & " WHERE Junction1.KeywordID IN (" & Mid(Criteria2, 2) & ")"
Me.LK.RowSource = MySql