Private Sub 查询_Click()
Dim strSQL As String
Dim strWhere As String
Dim ctl As Control
Dim varI As Variant
strSQL = "select * from 合并表 where True "
If Me.名称.ItemsSelected.Count > 0 Then
Set ctl = Me.名称
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.Column(0, varI) & "',"
Next
strSQL = strSQL & " And 名称 in (" & Left(strWhere, Len(strWhere) - 1) & ") "
End If
If Me.状态.ItemsSelected.Count > 0 Then
Set ctl = Me.状态
strWhere = ""
For Each varI In ctl.ItemsSelected
strWhere = strWhere & "'" & ctl.Column(0, varI) & "',"
Next
strSQL = strSQL & " And 状态 in (" & Left(strWhere, Len(strWhere) - 1) & ") "
End If