您好!大师:
这是表的筛选代码,请您帮我帮我优化.谢谢!!!
e.Form.StopRedraw
Dim Filter As String
With e.Form.Controls("款号")
If .Value IsNot Nothing Then
Filter = "vdmh = 1 and ffikgn = '" & .Value & "'"
End If
End With
With e.Form.Controls("xqsufjya")
If .Value IsNot Nothing Then
Filter = "vdmh = 1 and xqsufjya = '" & .Value & "'"
End If
End With
With e.Form.Controls("设计师")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "vdmh = 1 and ymyfjgm = '" & .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 & "vdmhjjad >= '" & .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 & "vdmhjjad <= '" & .Value & "'"
End If
End With
If e.Form.Controls("已审核").Checked = True ' 如果付款状态选择了"已付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "pjsy = 1"
End If
If e.Form.Controls("未审核").Checked = True '
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "vdmh = 1 and pjsy = 0"
If Filter > "" Then
End If
End If
If e.Form.Controls("fixqsu").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] <> ('纸样已完成')"
If Filter > "" Then
End If
End If
If e.Form.Controls("nnxqsu").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] = ('纸样已完成')"
If Filter > "" Then
End If
End If
If e.Form.Controls("filgsr").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] <> ('车板已完成')"
If Filter > "" Then
End If
End If
If e.Form.Controls("nnlgsr").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "vdmh = 1 and pjsy = 0 and [xqsufjya] = ('车板已完成')"
If Filter > "" Then
End If
End If
If e.Form.Controls("thnn").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "pjsy = 0 and xqsujgm = '" & User.Name & "'"
If Filter > "" Then
End If
End If
If e.Form.Controls("g").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "vdmhjjad = '" & Date.Today & "'"
If Filter > "" Then
End If
End If
If e.Form.Controls("f").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Dim dt As Date = Date.Today.AddDays(-3)
Filter = Filter & "vdmhjjad > '" & dt & "'"
If Filter > "" Then
End If
End If
If e.Form.Controls("d").Checked = True Then
If Filter >"" Then
Filter = Filter & " And "
End If
Dim dt As Date = Date.Today.AddDays(-7)
Filter = Filter & "vdmhjjad > '" & dt & "'"
If Filter > "" Then
End If
End If
Tables("qrymyf").Filter = Filter
DataTables("qrymyf").LoadFilter = Filter
DataTables("qrymyf").Load()
谢谢!