代码不要这样写,参考
Dim filter As String = ""
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If filter >"" Then
filter = filter & " And "
End If
filter = filter & "日期 = #" & .Value & "#"
End If
End With
With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
If filter > "" Then
filter = filter & " And "
End If
filter= filter & "归属部门 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox2")
If .Value IsNot Nothing Then
If filter > "" Then
filter= filter & " And "
End If
filter = filter & "做的好的人 = '" & .Value & "'"
End If
End With
Tables("行政主管日常工作1").filter = filter