Foxtable(狐表)用户栏目专家坐堂 → 怎么简化代码?


  共有2615人关注过本帖树形打印复制链接

主题:怎么简化代码?

帅哥哟,离线,有人找我吗?
31803263
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:71 积分:809 威望:0 精华:0 注册:2017/8/18 13:09:00
怎么简化代码?  发帖心情 Post By:2019/12/4 21:15:00 [显示全部帖子]

Dim Filter As String
With e.Form.Controls("ComboBox1")
    If .Value IsNot Nothing Then
        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

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("ComboBox3")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "摘要 like '%" & .Value & "%'"
       End If
End With

With e.Form.Controls("ComboBox4")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "金额= '" & .Value & "'"
    End If
End With

With e.Form.Controls("ComboBox5")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "实付= '" & .Value & "'"
    End If
End With

With e.Form.Controls("ComboBox6")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "报销人= '" & .Value & "'"
    End If
End With

With e.Form.Controls("ComboBox7")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "领款人= '" & .Value & "'"
    End If
End With

 回到顶部