Foxtable(狐表)用户栏目专家坐堂 → 如何将以下代码合在一起


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

主题:如何将以下代码合在一起

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


加好友 发短信
等级:幼狐 帖子:185 积分:1249 威望:0 精华:0 注册:2014/7/5 8:01:00
如何将以下代码合在一起  发帖心情 Post By:2014/7/23 7:13:00 [只看该作者]

你好,如何将以下两段代码合在一起,这样既能够模糊查询,又能根据日期查询。谢谢。



Dim Filter   As   String
With e.Form.Controls("染料代号")
    If .Value   IsNot   Nothing  Then
        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("StartDate")
    If .Value   IsNot   Nothing   Then
        If Filter >""   Then
            Filter = Filter &   " And "
        End   If
        Filter = Filter &   "日期 >= #" & .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 &   "日期 <= #" & .Value &   "#"
    End   If
End   With
If   Filter >   "" Then
    Tables("进仓").Filter =   Filter
************************************************************************


Dim filter As String
Dim sts() As String = {"染料代号","存货名称","供应商"}
For Each st As String In sts
    Dim var As String = e.Form.controls(st).value
    If var IsNot Nothing Then
        var = var.replace("*","[*]")
        If filter <> "" Then
            filter = filter & " And " & st & " Like '*" & var & "*'"
        Else
            filter = st & " like '*" & var & "*'"
        End If
    End If

Next
Tables("物料信息").filter = filter

 回到顶部
总数 26 1 2 3 下一页