With DataTables("总表")
Dim allname As List(Of String) = .GetValues("公司名称")
Dim s1 As String
Dim d As Date = Date.Today
s1 = d.year
Dim dr As DataRow
For Each name As String In allname
dr = .Find("年 = '" & s1 & "' and 公司名称 = '" & name & "'")
If dr IsNot Nothing Then
Dim str As String = "年 <= '" & d.year & "' And 月份 <= #" & d & "# and 公司名称 = '" & name & "'"
d = d.AddMonths(-12)
str &= " and 年 >= '" & d.year & "' and 月份 >= #" & d & "#"
Dim sum As Double = DataTables("明细表").Compute("sum(收入)", str)
dr("连续12月累计收入") = sum
End If
Next
End With
http://www.foxtable.com/help/topics/2747.htm