此主题相关图片如下:qq图片20181207143708.png
设置了很多个分类进行统计的按钮 都是统计“检测报告”这个表里的数据 但之前检测报告这个表是内部表 后面我把它转为外部表之前可以运行的功能就不行了 显示错误如图
其中一个按钮的代码为:
此主题相关图片如下:qq图片20181207143658.png
Dim b As New SQLGroupTableBuilder("统计表1","检测报告")
Dim d1 As Date = Date.Today
Dim year As Integer = d1.Year
Dim month As Integer = d1.Month
b.Groups.AddDef("检测日期",DateGroupEnum.Year,"年份")
b.Totals.AddExp("样品数量","实验室编号","",AggregateEnum.Count) '统计人数
Dim nms() As String = {"检测项目_蓝耳PRRS_判定","检测项目_猪瘟CSFV_判定","检测项目_猪伪狂犬gB_判定","检测项目_猪伪狂犬gE_判定","检测项目_猪圆环病毒_判定"}
For Each nm As String In nms '利用表达式统计及格人数和优秀人数
b.Totals.Addexp(nm & "_阳性", "iif(" & nm & " = 'P', 1, 0)")
b.Totals.Addexp(nm & "_可疑", "iif(" & nm & " = 'S', 1, 0)")
Next
b.VerticalTotal = True
b.Build()
For Each nm As String In nms '对生成的统计表增加表达式列,计算及格率和优秀率
DataTables("统计表1").DataCols.Add(nm & "_阳性率",Gettype(Double), nm & "_阳性/样品数量" )
Tables("统计表1").Cols(nm & "_阳性率").Move(Tables("统计表1").Cols(nm & "_阳性").Index + 1)
DataTables("统计表1").DataCols.Add(nm & "_可疑率",Gettype(Double), nm & "_可疑/样品数量" )
Tables("统计表1").Cols(nm & "_可疑率").Move(Tables("统计表1").Cols(nm & "_可疑").Index + 1)
DataTables("统计表1").DataCols(nm & "_阳性率").SetFormat("0.00%")
DataTables("统计表1").DataCols(nm & "_可疑率").SetFormat("0.00%")
Next
MainTable = Tables("统计表1")
MainTable = Tables("统计表1")
Forms("返回").OpenTo("统计表1")
MainTable.Focus()