以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  根定指定列名进行查询内容  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=179929)

--  作者:nuoyan89
--  发布时间:2022/9/19 9:23:00
--  根定指定列名进行查询内容
老师,我想在内容处输入列名,查询条件输入内容,点击条件筛选时我想在项目编码中查询结果,如果内容为项目名称,则在项目名称列中查询,现在代码如下:
Dim Filter As String
With e.Form.Controls("项目编码1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "项目编码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("预计开始日期1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "预计开始日期 >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("预计结束日期1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "预计开始日期 < \'" & .Value.adddays(1)& "\'"
    End If
End With
With e.Form.Controls("项目名称1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "项目名称 like \'%" & .Value & "%\'"
    End If
End With
If Filter >"" Then
    e.Form.controls("项目总表").Table.DataTable.LoadPage = 0
    e.Form.controls("项目总表").Table.DataTable.LoadFilter = Filter
    e.Form.controls("项目总表").Table.DataTable.Load
End If

图片点击可在新窗口打开查看此主题相关图片如下:1.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2022/9/19 9:49:00
--  
Dim Filter As String
With e.Form.Controls("查询条件")
    If .Value IsNot Nothing Then
if e.Form.Controls("内容").Value is nothing then
msgbox("没有选择列名")
return
end if
        Filter = Filter & e.Form.Controls("内容").Value & " = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("预计开始日期1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
……