老师您好!我想做一个业绩筛选,在窗口有一个CheckedComboBox控件可以多值和一个筛选按钮,不知道对于CheckedComboBox控件多值筛选代码怎么写?请老师指教。谢谢!
这个单值可以筛选,如下图:
此主题相关图片如下:qq图片20171201125538.jpg
但是二个以上的多选就不行了,如下图:
此主题相关图片如下:qq图片20171201125527.jpg
按钮代码:
Dim Filter As String
With e.Form.Controls("CheckedComboBox2")
If .Value IsNot Nothing Then
Filter = "所属省份 = '" & .Value & "'"
End If
End With
With e.Form.Controls("TextBox2")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "施工区域 = '" & .Value & "'"
End If
End With
With e.Form.Controls("NumericComboBox1")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "实际造价 >= '" & .Value & "'"
End If
End With
With e.Form.Controls("StartDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "开工日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "竣工日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("工程合同基础数据").Filter = Filter
End If
Dim lbl As WinForm.Label
lbl = e.Form.Controls("Label5")
lbl.Text = "符合条件工程数:" & Tables("工程合同基础数据").Rows.Count & "个"