各位前辈,我现在正在做一个报账程序,基本上做好了,现在在数据筛选上遇到了点小问题。我现在想实现在精确搜索的前提下,再进行一次模糊搜索,进一步得到自己想要的数据。如图:
此主题相关图片如下:01.bmp
。类别选择“办公费”点击搜索正常。但是在精确定位文本框输入“加班”再一次进行定位之后,显示就不正常啦,筛选出来的数据不是 在“办公费”的条件下筛选出来的含有“加班”字眼的数据,而是全部含有“加班”字眼的数据。“查询”按钮的代码如下:
Dim Filter As String
With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
Filter = "类别 = '" & .Value & "'"
End If
End With
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("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "维修日期 <= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker3")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "报销日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker4")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "报销日期 <= #" & .Value & "#"
End If
End With
With e.Form.Controls("TextBox1")
Dim txt,fl As String
txt= .Text
txt = "'*" & txt & "*'"
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
fl="[项目部] Like " & txt & " Or [车牌号] Like " & txt & " Or [报销人] Like " & txt & " Or [司机] Like " & txt & " Or [维修事项] Like " & txt
Filter = Filter & fl
End I
End With
If Filter > "" Then
Tables("费用表").Filter = Filter
End If
麻烦看一看哪里写错了,这个程序不麻烦,就是一个筛选功能,幸亏各位前辈了,在线等候消息。