-- 作者:yyzlxc
-- 发布时间:2013/3/29 19:26:00
-- [求助]代码运行出错(已解决)
以下是一段生成“统计表”的代码,黑色部分运行正常,加了红色代码后运行出错,不知原因在哪里,请各位老师指教,谢谢!!
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编辑过]
|
-- 作者:e-png
-- 发布时间:2013/3/29 22:06:00
--
Dim b As New GroupTableBuilder("统计表",sql,"SCGL")
===================================================
Dim b As New
SQLGroupTableBuilder("统计表1","订单") b.ConnectionName = "Sale"
没看懂你的代码,为何不直接用Fill呢?
|
-- 作者:狐狸爸爸
-- 发布时间:2013/3/30 11:01:00
--
错误原因很清楚啊,你定义了:
Dim nd2,nd3 As WinForm.RadioButton
但是nd2和nd3没有指定值,只是定义了变量,所以下面的代码会出错:
If nd2.Checked = True Then ‘按正常时间段统计
你的加上:
Dim nd2,nd3 As WinForm.RadioButton
nd2 = e.form.Controls("控件名称") nd3 = e.form.Controls("控件名称")
|