Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
我在表事件CurrentChanged中设置下面的代码:
With CurrentTable
Dim r As Row = .Current
此主题相关图片如下:sd.jpg
Dim c As Integer=.Cols("正班工资").Index
Dim cj As Integer=.Cols("数据状态").Index
dim v as String=.Text(.Position,C)
dim sj as String=.Text(.Position,cj)
Dim Sum As Double
Sum = .DataTable.Compute("Sum(正班工资)", "[日期] = '" & r("日期") & "'" And "[工号] = '" & r("工号") & "'")
Dim Str1 As String = "工资信息: 日期: " & r("日期") & " 工号:" & r("工号") & " 姓名:" & r("姓名") & " 正班工资:" & V
Str1 = Str1 & " 当前行号: " & "( " & (.Position + 1) & " ) 数据状态:" & sj & sum
StatusBar.Message1 = Str1
End With
提示错误如附件所示,不知错在那里呢?
如果工号是字符:
Sum = DataTable("XXX").Compute("Sum(正班工资)", "[日期] = #" & r("日期") & "# And [工号] = '" & r("工号") & "'")
如果工号是数值
Sum = DataTable("XXX").Compute("Sum(正班工资)", "[日期] = #" & r("日期") & "# And [工号] = " & r("工号") )
我的代码现在是:
With CurrentTable
Dim r As Row = .Current
Dim c As Integer=.Cols("正班工资").Index
Dim cj As Integer=.Cols("数据状态").Index
dim v as String=.Text(.Position,C)
dim sj as String=.Text(.Position,cj)
Dim Sum As Double
Sum = .Compute("Sum(正班工资)", "[日期] = #" & r("日期") & "# And [工号] = '" & r("工号") & "'")
Dim Str1 As String = "工资信息: 日期: " & r("日期") & " 工号:" & r("工号") & " 姓名:" & r("姓名") & " 正班工资:" & V
Str1 = Str1 & " 当前行号: " & "( " & (.Position + 1) & " ) 数据状态:" & sj & sum
StatusBar.Message1 = Str1
End With
但计算SUM的数量不是按我的条件计的,而是等于本行的正班工资,不是我要的各行合计工资数,请问原因何在呢?
Compute不会有问题的,有问题的是你给定的条件,仔细检查。
你的条件是和当前行同一日期和同一工号的“正班工资”汇总。
呵呵,不好意思,我看错了。