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


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

主题:怎么简化代码?

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


加好友 发短信
等级:婴狐 帖子:46 积分:491 威望: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

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:39143 积分:199043 威望:0 精华:8 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/5 9:25:00 [只看该作者]

简化不了

 回到顶部