-- 作者:青丘狐
-- 发布时间:2023/1/31 19:52:00
--
Dim Filter As String Dim KJMC() As String = {"摘要","经手人"} For Each MC As String In KJMC Dim val As String = e.Form.Controls(MC).value If val > "" Then val = val.Replace("*", "[*]") If filter = "" Then filter = MC & " like \'*" & val & "*\'" Else filter = filter & " and " & MC & " like \'*" & val & "*\'" End If End If Next
With e.Form.Controls("收入") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "收入 = \'" & .Value & "\'" End If End With
With e.Form.Controls("支出") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "支出 = \'" & .Value & "\'" End If End With With e.Form.Controls("开始日期") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "日期 >= #" & .Value & "#" End If End With With e.Form.Controls("结束日期") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "日期 <= #" & .Value & "#" End If End With
If e.Form.Controls("方向借").Checked = True Then\' 如果收入选择了"借" If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "方向 = True" End If If e.Form.Controls("方向贷").Checked = True Then\' 如果支出选择了"贷" If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "方向 = False Or 方向 Is Null" End If
With e.Form.Controls("收入从") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "收入 >= \'" & .Value & "\'" End If End With With e.Form.Controls("收入到") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "收入 <= \'" & .Value & "\'" End If End With
With e.Form.Controls("支出从") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "支出 >= \'" & .Value & "\'" End If End With With e.Form.Controls("支出到") 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
谢谢老师解决了
|