利用列表框可以多选的特性,实现多条件查询:
首先把列表框属性[多重选择]设置“简单”
代 码:
Dim vari As Variant
Dim strWhere As String
Dim strSQL As String
strSQL = "Select * FROM 提前文理查询"
With Me.学校名称
If .ItemsSelected.Count = 0 Then Exit Sub
For Each vari In .ItemsSelected
strWhere = strWhere & "'" & .Column(0, vari) & "',"
Next
End With
strWhere = Left(strWhere, Len(strWhere) - 1)
strSQL = strSQL & " where [学校名称] in (" & strWhere & ")"
' Debug.Print strSQL
Me.提前文理查询子窗体.Form.RecordSource = strSQL
附 件:
点击下载此附件
图 示: