后来我这样写进去了 但是提示错误 错误代码是Object reference not set to an instance of an object.
以下是我的全部代码
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.filter="检测日期>=#"&date.today.adddays(-6)&"#"
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()