请按照下面(红色部分)的进行修改
Private Sub Command4_Click()
Dim strSQl As String
Dim strWhere As String
Dim ctl As Control
Dim varI As Variant
strSQl = "select * from 综合查询 where True "
If Me.sfYE.ItemsSelected.Count > 0 Then
Set ctl = Me.sfYE
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & ctl.Column(0, varI) & ","
Next
strSQl = strSQl & " And sfYE in (" & Mid(strWhere, 1, Len(strWhere) - 1) & ") "
'sfYE是列表框名?字段名?不清楚,sql = sql & " [商品条形码]='" & Me![商品条形码]&"'"
End If
If Me.sfyNM.ItemsSelected.Count > 0 Then
Set ctl = Me.sfyNM
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.Column(0, varI) & "',"
Next
strSQl = strSQl & " And sfyNM in (" & Mid(strWhere, 1, Len(strWhere) - 1) & ") "
'sfyNM是列表框名?字段名?不清楚
End If
If Me.ldNM.ItemsSelected.Count > 0 Then
Set ctl = Me.ldNM
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.Column(0, varI) & "',"
Next
strSQl = strSQl & " And ldNM in (" & Mid(strWhere, 1, Len(strWhere) - 1) & ") "
'ldNM是列表框名?字段名?不清楚
End If
If Me.czrNM.ItemsSelected.Count > 0 Then
Set ctl = Me.czrNM
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.Column(0, varI) & "',"
Next
strSQl = strSQl & " And czrNM in (" & Mid(strWhere, 1, Len(strWhere) - 1) & ") "
'czrNM是列表框名?字段名?不清楚
End If
' Debug.Print strSQl
' Me.筛选结果.Form.RecordSource = strSQl
CurrentDb.QueryDefs("综合查询1").sql = strSQl
Me.筛选结果.Form.RecordSource = "综合查询1"
End Sub