以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]关联表统计问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=2401)

--  作者:狐哥
--  发布时间:2009/4/11 12:21:00
--  [求助]关联表统计问题
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:跨表统计.table


求助各位老师

统计 表中我已录入结果,如何统计关联表 柜型 中的数量

非常感谢.
--  作者:don
--  发布时间:2009/4/11 13:31:00
--  

必須去掉數據中的『\'』才能統計,因『\'』在狐表中比較特殊:表達式中,字符串用单引号引用.

Dim T,Tj,T1,Ts As String
Dim Ls As List(Of String)
Dim dt As DataTable = DataTables("柜型")

For Each r As Row In Tables("统计").Rows
    T = "关联 = " & r("_Identify")
    Ls = dt.GetUniqueValues( T ,"柜型")
    For Each T1 In Ls
        Tj = T & " and 柜型 = \'" & T1 & "\'"
        Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
    Next
    r("统计")=Ts.substring(1)
    Ts =Nothing
Next


--  作者:狐哥
--  发布时间:2009/4/11 13:32:00
--  
感谢大师!
--  作者:don
--  发布时间:2009/4/11 14:37:00
--  

這樣可以不必去掉數據中的『\'

一:按鈕

Dim T,Tj,T1,Ts As String
Dim Ls As List(Of String)
Dim dt As DataTable = DataTables("柜型")

For Each r As Row In Tables("统计").Rows
    T = "关联 = " & r("_Identify")
    Ls = dt.GetUniqueValues( T ,"柜型")
   
    if Ls.count > 0 then
        For Each T1 In Ls
            Tj = T & " and 柜型 = \'" & T1.Replace("\'","\'\'") & "\'"
            Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
        Next
        r("统计")=Ts.substring(1)
        Ts =Nothing
    end if
Next


二:DataColChanged事件

If e.DataCol.Name = "柜型" Then
    Dim dr,pr As DataRow
    dr = e.DataRow
    pr = dr.GetParentRow("统计")
   
    if pr isnot nothing then
        Dim T,Tj,T1,Ts As String
        Dim Ls As List(Of String)        
        Dim dt As DataTable = DataTables("柜型")
       
        T = "关联 = " & dr("关联")
        Ls = dt.GetUniqueValues( T ,"柜型")
        For Each T1 In Ls
            Tj = T & " and 柜型 = \'" & T1.Replace("\'","\'\'") & "\'"
            Ts = Ts & " " & dt.Compute("Count(柜型)",Tj) & "×" & T1
        Next
        pr("统计") =Ts.substring(1)
    End If
End If

[此贴子已经被作者于2009-4-11 14:55:49编辑过]

--  作者:狐哥
--  发布时间:2009/4/11 15:17:00
--  

再次感谢大师!