以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]后台数据统计  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=114084)

--  作者:沪上游客
--  发布时间:2018/1/28 14:04:00
--  [求助]后台数据统计
老师你好!
我原来在项目中设置了按窗口控件条件筛选数据,如下图:

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20180128140546.png
图片点击可在新窗口打开查看

开始按钮中的代码为:
Dim Filter As String
With e.Form.Controls("CheckedComboBox2")
    If .Value IsNot Nothing Then
         Filter = "所属省份 in (\'" & .Value.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("CheckedComboBox1")
    If .Value IsNot Nothing Then
         Filter = "项目类型 In (\'" & .Value.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "施工区域 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "最大承载力KN >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox3")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "最深桩长m >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox4")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "最大桩径mm >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox5")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "基坑深度m >= \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("NumericComboBox1")
    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 e.Form.Controls("在建工程").Checked = True \' 如果选择了"在建工程"
         If Filter >"" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "竣工日期 >= #" & Date.Today & "#" 
End If
If Filter > "" Then
    Tables("工程技术参数").Filter = Filter
End If
Dim t As Table = Tables("工程技术参数")
Dim n As Integer = t.DataTable.GetValues("合同编号", t.filter).count
Dim lbl As WinForm.Label
lbl = e.Form.Controls("Label5")
lbl.Text = "符合条件工程数:" & n & "个," & "记录数:" & Tables("工程技术参数").Rows.Count & "条."

现在我的项目是按照条件加载数据,以上代码是按照已加载数据执行,需要按照后台数据筛选,代码应该怎么改?
谢谢老师!
[此贴子已经被作者于2018/1/28 14:07:50编辑过]

--  作者:有点甜
--  发布时间:2018/1/28 14:59:00
--  

Tables("工程技术参数").Filter = Filter

 

改成

 

Tables("工程技术参数").DataTable.LoadFilter = Filter

Tables("工程技术参数").DataTable.Load


--  作者:沪上游客
--  发布时间:2018/1/29 10:04:00
--  
老师还是不行,代码改后还是和原来一样,没有显示未加载数据。
另外我这个表是和“工程合同基础数据”(主表)有关联,有表达式列公式。
是不是要生成一个临时表,再生成?
谢谢!
[此贴子已经被作者于2018/1/29 10:06:15编辑过]

--  作者:有点甜
--  发布时间:2018/1/29 10:06:00
--  

那改成

 

Tables("工程技术参数").DataTable.LoadPage = 0

Tables("工程技术参数").DataTable.LoadTop = ""

Tables("工程技术参数").DataTable.LoadFilter = Filter

Tables("工程技术参数").DataTable.Load


--  作者:沪上游客
--  发布时间:2018/1/29 11:56:00
--  
老师还是不行
--  作者:有点甜
--  发布时间:2018/1/29 12:08:00
--  
以下是引用沪上游客在2018/1/29 11:56:00的发言:
老师还是不行

 

那是否报错?如果不报错,那不应该,实例发上来测试。


--  作者:沪上游客
--  发布时间:2018/1/29 12:53:00
--  
老师你好!我已发邮件给您了,请查收帮我看一下整个项目有什么问题?谢谢!
--  作者:沪上游客
--  发布时间:2018/1/29 13:05:00
--  
老师你好!能给个QQ吗?传不上,文件太大了。
--  作者:有点甜
--  发布时间:2018/1/29 14:40:00
--  

1、贴出你写的全部代码;

 

2、加入msgbox,看弹出的filter是什么,有没有执行里面改的Load代码?


--  作者:沪上游客
--  发布时间:2018/1/29 15:23:00
--  
Dim Filter As String
With e.Form.Controls("CheckedComboBox2")
    If .Value IsNot Nothing Then
        Filter = "所属省份 in (\'" & .Value.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("CheckedComboBox1")
    If .Value IsNot Nothing Then
        Filter = "项目类型 In (\'" & .Value.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "施工区域 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "最大承载力KN >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox3")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "最深桩长m >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox4")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "最大桩径mm >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox5")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "基坑深度m >= \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("NumericComboBox1")
    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 e.Form.Controls("在建工程").Checked = True \' 如果选择了"在建工程"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "竣工日期 >= #" & Date.Today & "#"
End If
If Filter > "" Then
    Tables("工程技术参数").DataTable.LoadTop = Nothing
    Tables("工程技术参数").DataTable.LoadFilter = ""
    Tables("工程技术参数").DataTable.Load
End If
Dim t As Table = Tables("工程技术参数")
Dim n As Integer = t.DataTable.GetValues("合同编号", t.filter).count
Dim lbl As WinForm.Label
lbl = e.Form.Controls("Label5")
lbl.Text = "符合条件工程数:" & n & "个," & "记录数:" & Tables("工程技术参数").Rows.Count & "条."