4,816
社区成员
发帖
与我相关
我的任务
分享
在页眉中声明全局变量:小计,和总计
WhilePrintingRecords;
Global numbervar tot := 0;
Global numbervar hjamt := 0
在详细资料中用公式字段写条件统计,去空,去重复,就是这里有BUG
WhilePrintingRecords;
if Trim ({GJRPT02.FLAGTSRF})<>""
then Global numbervar tot := tot + {GJRPT02.SWAMNT};
global numbervar hjamt:=hjamt+tot;
if Trim(Previous({GJRPT02.FLAGTSRF}))={GJRPT02.FLAGTSRF} then
tot := tot - {GJRPT02.SWAMNT};
tot;
在组页脚中清空,因为是每组小计
EvaluateAfter ({@xj});
Global numbervar tot :=0;
WhileprintingRecords
global t as double '统计值
dim thisField as string '当前字段
global m as string '监视步骤
global z as double '控制最后一条
'判断组切换,重置变量
if {Test001.A} <> PreviousValue ({Test001.A}) then t=0
thisField=iif(isnull({Test001.D}),"",{Test001.D})
if onfirstrecord and thisField<>"" then
if NextIsNull ({Test001.D}) or Nextvalue ({Test001.D})="" then
t=t+{Test001.E}
else
if thisField<>nextvalue({Test001.D}) then
t=t+{Test001.E}
end if
end if
m=m & "111"
end if
if onlastrecord and thisField<>"" and z=0 then
z=z+1
if PreviousIsNull ({Test001.D}) or Previousvalue ({Test001.D})="" then
t=t+{Test001.E}
else
if thisField<>PreviousValue({Test001.D}) then
t=t+{Test001.E}
end if
end if
'formula=t
m=m & "222"
end if
'如果不是第一条也不是最后一条
if not onlastrecord and not onfirstrecord and thisField<>"" then
'if not onlastrecord and thisField<>"" then
'判断前一条是否为空
'如果为空
if PreviousIsNull ({Test001.D}) or Previousvalue ({Test001.D})="" then
t=t+{Test001.E}
m=m & "333"
'如果前一条不为空
else
'判断本条和前一条是否一样
'如果不一样,
if thisField<>PreviousValue({Test001.D}) then
'继续判断本条跟下一条是否一样,如果不一样,则符合条件
'if thisField<>nextvalue({Test001.D}) then
t=t+{Test001.E}
'end if
end if
m=m & "444"
end if
end if
'formula= cstr(t) & m
formula= t