Foxtable(狐表)用户栏目专家坐堂 → [求助]简化代码


  共有3057人关注过本帖平板打印复制链接

主题:[求助]简化代码

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


加好友 发短信
等级:幼狐 帖子:163 积分:1306 威望:0 精华:0 注册:2015/6/11 22:37:00
[求助]简化代码  发帖心情 Post By:2015/8/1 12:42:00 [只看该作者]

With Tables("台账查询_table1")
    If e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" And e.Form.Controls("DropBox1").text ="" Then
        .filter =""
    Else
        If e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" Then
            .filter = "品号 = '" & e.Form.Controls("DropBox1").text & "' "
        Else
            If e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" And e.Form.Controls("DropBox1").text ="" Then
                .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' "
            Else
                If  e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker2").text ="" And e.Form.Controls("DropBox1").text ="" Then
                    .filter ="日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# "
                Else
                    If  e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DropBox1").text ="" Then
                        .filter = "日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# "
                    Else
                        If e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" Then
                           
                            .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "'and 品号 ='" & e.Form.Controls("DropBox1").text & "' "
                        Else
                            If e.Form.Controls("DropBox1").text="" And e.Form.Controls("DateTimePicker1").text="" Then
                                .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# "
                            Else
                                If e.Form.Controls("DateTimePicker2").text="" And e.Form.Controls("DropBox1").text="" Then
                                    .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" & e.Form.Controls("DateTimePicker1").text & "# "
                                Else
                                    If e.Form.Controls("DropBox1").text ="" And e.Form.Controls("ComboBox1").text="" Then
                                        .filter ="日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# "
                                    Else
                                        If e.Form.Controls("DateTimePicker1").text="" And e.Form.Controls("ComboBox1").text="" Then
                                            .filter = "日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 ='" & e.Form.Controls("DropBox1").text & "' "
                                        Else
                                            If e.Form.Controls("DateTimePicker1").text="" And e.Form.Controls("ComboBox1").text="" Then
                                                .filter = "日期 >= #" & e.Form.Controls("DateTimePicker1").text & "# and 品号 ='" & e.Form.Controls("DropBox1").text & "' "
                                            Else
                                               
                                               
                                                If e.Form.Controls("DropBox1").text ="" Then
                                                    .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# "
                                                Else
                                                    If e.Form.Controls("ComboBox1").text = "" Then
                                                        .filter = "日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
                                                    Else
                                                        If e.Form.Controls("DateTimePicker1").text="" Then
                                                            .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
                                                           
                                                        Else
                                                            If e.Form.Controls("DateTimePicker2").text="" Then
                                                                .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
                                                            Else
                                                                .filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
                                                            End If
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End If

End With

 

那位大神能帮忙简化下代码


 回到顶部