G
Guest
I have a parameterized query (qrySAR_Status_by_IR) that I am passing a string
to through a form:
SELECT tblSAR.SAR_ID, tblSAR.SAR_Multipurpose
FROM tblSAR
WHERE (((tblSAR.SAR_Multipurpose) Like
[Forms]![frmMain]![txtBuildParameter]));
I am building the string through a multi-select list box on the form:
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & "*" & ctl.ItemData(varItem) & "*" _
& " OR (tblSAR.SAR_Multipurpose) Like "
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, (Len(strSQL) - 35))
Me.txtBuildParameter = strSQL
DoCmd.OpenQuery "qrySAR_Status_by_IR"
This code works as expected with one selection, but returns nothing when two
or more items are selected. A Debug.Print on strSQL returns:
*IR-7* ' For one selection--and this works
*IR-7* OR (tblSAR.SAR_Multipurpose) Like *IR-8* 'For two selections--which
does not work
Any idea what I am doing wrong?
Thank you,
Judy
to through a form:
SELECT tblSAR.SAR_ID, tblSAR.SAR_Multipurpose
FROM tblSAR
WHERE (((tblSAR.SAR_Multipurpose) Like
[Forms]![frmMain]![txtBuildParameter]));
I am building the string through a multi-select list box on the form:
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & "*" & ctl.ItemData(varItem) & "*" _
& " OR (tblSAR.SAR_Multipurpose) Like "
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, (Len(strSQL) - 35))
Me.txtBuildParameter = strSQL
DoCmd.OpenQuery "qrySAR_Status_by_IR"
This code works as expected with one selection, but returns nothing when two
or more items are selected. A Debug.Print on strSQL returns:
*IR-7* ' For one selection--and this works
*IR-7* OR (tblSAR.SAR_Multipurpose) Like *IR-8* 'For two selections--which
does not work
Any idea what I am doing wrong?
Thank you,
Judy