Foxtable(狐表)用户栏目专家坐堂 → 列表查询


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

主题:列表查询

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


加好友 发短信
等级:幼狐 帖子:155 积分:1556 威望:0 精华:0 注册:2011/4/8 14:38:00
列表查询  发帖心情 Post By:2013/3/29 13:05:00 [显示全部帖子]

以下是列表中【查询】按钮的代码:
Dim Filter As String
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "LCMC like '*" & .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 & "RQ >= #" & .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 & "RQ <= #" & .Value & "#"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        Filter = "KHBM like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "KHMC like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "LXR like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "LXDH like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "SHDZ like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "SSXQ like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "XSQD like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "KHDJ like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "BBBM like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "BBYWY like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "BBDGY like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "GZZT like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "BZ like '*" & .Value & "*'"
    End If
End With
If Filter > "" Then
    Tables("YXKH").Filter = Filter
End If
-------------------------------------------------------------------------
问题:我把其他字段的的条件注释掉,单独只留LCMC(如下),执行查询是正常的,但是像上面那样,全部执行的时候,LCMC这个字段的条件就失效,求解!
Dim Filter As String
With e.Form.Controls("模糊条件")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " OR "
        End If
        Filter = Filter & "LCMC like '*" & .Value & "*'"
    End If
End With
If Filter > "" Then
    Tables("YXKH").Filter = Filter
End If

 回到顶部