Foxtable(狐表)用户栏目专家坐堂 → 在范围内查询


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

主题:在范围内查询

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


加好友 发短信
等级:小狐 帖子:348 积分:2679 威望:0 精华:0 注册:2018/11/11 15:52:00
在范围内查询  发帖心情 Post By:2023/1/30 23:50:00 [只看该作者]

 

Dim Filter As String
Dim KJMC() As String = {"摘要","经手人"}
For Each MC As String In KJMC
    Dim val As String = e.Form.Controls(MC).value
    If val > "" Then
        val = val.Replace("*", "[*]")
        If filter = "" Then
            filter = MC & " like '*" & val & "*'"
        Else
            filter = filter & " and " & MC & " like '*" & val & "*'"
        End If
    End If
Next

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("开始日期")
    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


If e.Form.Controls("方向借").Checked = True Then' 如果收入选择了"借"
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "方向 = True"
End If
If e.Form.Controls("方向贷").Checked = True Then' 如果支出选择了"贷"
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "方向 = False Or 方向 Is Null"
End If

If Filter > "" Then
    Tables("收支明细表").Filter = Filter
End If

 

请问要增加一个收入在范围内查询 比如从5到10的范围内查询,支出在范围内查询比如从5到10的范围内查询,请问要怎么改条件代码?


此主题相关图片如下:0130.png
按此在新窗口浏览图片

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/1/31 8:36:00 [只看该作者]

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

 回到顶部
帅哥哟,离线,有人找我吗?
青丘狐
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:348 积分:2679 威望:0 精华:0 注册:2018/11/11 15:52:00
  发帖心情 Post By:2023/1/31 19:52:00 [只看该作者]

Dim Filter As String
Dim KJMC() As String = {"摘要","经手人"}
For Each MC As String In KJMC
    Dim val As String = e.Form.Controls(MC).value
    If val > "" Then
        val = val.Replace("*", "[*]")
        If filter = "" Then
            filter = MC & " like '*" & val & "*'"
        Else
            filter = filter & " and " & MC & " like '*" & val & "*'"
        End If
    End If
Next

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("开始日期")
    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


If e.Form.Controls("方向借").Checked = True Then' 如果收入选择了"借"
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "方向 = True"
End If
If e.Form.Controls("方向贷").Checked = True Then' 如果支出选择了"贷"
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "方向 = False Or 方向 Is Null"
End If


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("支出从")
    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


If Filter > "" Then
    Tables("收支明细表").Filter = Filter
End If

 

谢谢老师解决了


 回到顶部