以下是一段生成“统计表”的代码,黑色部分运行正常,加了红色代码后运行出错,不知原因在哪里,请各位老师指教,谢谢!!
Dim sql As String
Dim nd2,nd3 As WinForm.RadioButton
If dw <> "" Then ’dw 不为空时,按单位统计
If nd2.Checked = True Then ‘按正常时间段统计
sql = "Select 报表年月 As 年月,日期,单位,Sum(加工费) As 加工费,Sum(投工) As 月均人数 FROM {日报源表} WHERE 报表年月 >= '" & nc & "' And 报表年月 <= '" & ny & "' And 单位 = '" & dw & "' Group By 报表年月,日期,单位 " '年截止月
Dim b As New GroupTableBuilder("统计表",sql,"SCGL")
b.Groups.AddDef("年月")
b.Totals.AddDef("加工费")
b.Totals.AddDef("月均人数",AggregateEnum.Average)
b.Build()
ElseIf nd3.Checked = True Then '按特殊时间段统计
sql = "Select 报表年月 As 年月,日期,单位,Sum(加工费) As 加工费,Sum(投工) As 月均人数 FROM {日报源表} WHERE 报表年月 >= '" & qc & "' And 报表年月 <= '" & ny & "' And 单位 = '" & dw & "' Group By 报表年月,日期,单位 " '年截止月
Dim b As New GroupTableBuilder("统计表",sql,"SCGL")
b.Groups.AddDef("年月")
b.Totals.AddDef("加工费")
b.Totals.AddDef("月均人数",AggregateEnum.Average)
b.Build()
End If
Else 'dw 为空时,按合计统计
If nd2.Checked = True Then '按正常时间段统计
sql = "Select 报表年月 As 年月,日期,Sum(加工费) As 加工费,Sum(投工) As 月均人数 FROM {日报源表} WHERE 报表年月 >= '" & nc & "' And 报表年月 <= '" & ny & "' Group By 报表年月,日期" '年截止月
Dim b As New GroupTableBuilder("统计表",sql,"SCGL")
b.Groups.AddDef("年月")
b.Totals.AddDef("加工费")
b.Totals.AddDef("月均人数",AggregateEnum.Average)
b.Build()
ElseIf nd3.Checked = True Then ‘按特殊时间段统计
sql = "Select 报表年月 As 年月,日期,Sum(加工费) As 加工费,Sum(投工) As 月均人数 FROM {日报源表} WHERE 报表年月 >= '" & qc & "' And 报表年月 <= '" & ny & "' Group By 报表年月,日期" '年截止月
Dim b As New GroupTableBuilder("统计表",sql,"SCGL")
b.Groups.AddDef("年月")
b.Totals.AddDef("加工费")
b.Totals.AddDef("月均人数",AggregateEnum.Average)
b.Build()
End If
End If
此主题相关图片如下:a.png
[此贴子已经被作者于2013-3-30 11:48:28编辑过]