I know, it's a long post but please bear with me...
I am trying to pass the string results from a Multi Select list box to an existing SQL row source for a different lb. Two questions: 1) Is the following a reasonable approach? 2) If so, what might I use to pass the string to the existing SQL?
The row source in the dependent lb relies upon selections for four other lbs. I've tested the first three independently and then together and all is well. I am currently unable to integrate the final lb (which is the MS lb) into the row source for the dependent lb.
The particulars:
The three working source lbs are listHLBTeams, listMLBTeams and listPlayerYears. These are not MS.
The MS ls with which I am struggling is listPositions.
The lb with the results (dependent) is listPlayers.
My current approach is to use an After Update event with the following code I plagiarized and adapted to generate a string (strSQL) from the selections in listPositions. The string generated is exactly as I tested by manually entering into the criteria on the design view for the SQL driving the row source on listPlayers. Such as ""L-R" Or "Cf""
Code:
Private Sub listPositions_AfterUpdate()
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
'Set frm = Form!frmCardByPosition
Set ctl = Me.listPositions
strSQL = """" & Me.listPositions.Value
'enumerate selected items and
'concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & """ Or """
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 4)
Me.txtEvalPositionsSelected = strSQL
Me.listPlayer.Requery
Me.txtImageRecordControl = Null
End Sub
However, I cannot come up with a function in the criteria window to use strSQL. This is the current code for the row source of the dependent lb without any attempt at passing the string from listPositions.
Code:
SELECT tblPlayers.PlayerID, tblPlayers.NameLast, tblPlayers.NameFirst, tblPlayerYear.PlayerYear, tblMLBTeams.City, tblMLBTeams.Club, tblPlayers.HLBTeamID, tblPlayers.MLBTeamID, tblPlayers.PlayerYearIDFK, tblPlayers.Pos1
FROM tblPlayerYear INNER JOIN (tblMLBTeams INNER JOIN tblPlayers ON tblMLBTeams.MLBTeamID = tblPlayers.MLBTeamID) ON tblPlayerYear.PlayerYearID = tblPlayers.PlayerYearIDFK
WHERE (((tblPlayers.HLBTeamID) Like [Forms]![frmCardByPosition]![listHLBTeam]) AND ((tblPlayers.MLBTeamID) Like [Forms]![frmCardByPosition]![listMLBTeam]) AND ((tblPlayers.PlayerYearIDFK) Like [Forms]![frmCardByPosition]![listPlayerYear]))
ORDER BY tblPlayers.NameLast, tblPlayers.NameFirst, tblPlayerYear.PlayerYear, tblMLBTeams.City, tblMLBTeams.Club;
My research continues but, in advance, any insight or assistance is greatly appreciated.