以下是引用有点甜在2018/8/15 17:09:00的发言:
删除这两句
Tables("统计1").Select(-1,-1)
b.Build '生成统计表
改成
forms("窗口1").controls("Table1").Table.DataSource = b.BuildDataSource()
forms("窗口1").controls("Table1").Table.select(-1,-1)
老师,这是我统计窗口中确定按钮的所有代码:
''定义数据三个统计1\2\3的数据字典,便于引用显示值
Dim dmp1 = Tables("统计1").cols("分组列").DataMap
Dim dmp2 = Tables("统计2").cols("分组列").DataMap
Dim dmp3 = Tables("统计3").cols("统计列").DataMap
Dim b As New SQLCrossTableBuilder("统计表1","person")
''数据库指定
b.C
''设置水平分组
For Each r As Row In Tables("统计1").Rows
If r.IsNull("分组列")=False Then
If r.IsNull("日期分组")=False Then
If r("日期分组") = "年" Then
b.VGroups.AddDef(r("分组列"), DateGroupEnum.Year, r("标题") )
ElseIf r("日期分组") = "月" Then
b.VGroups.AddDef(r("分组列"), DateGroupEnum.Month, r("标题") )
End If
Else
b.HGroups.AddDef(r("分组列"),r("标题") )'添加列用于水平分组
End If
End If
Next
''设置垂直分组
For Each r As Row In Tables("统计2").Rows
If r.IsNull("分组列")=False Then
If r.IsNull("日期分组")=False And r.IsNull("模式")=False Then
If r("日期分组") = "年" Then
b.VGroups.AddDef(r("分组列"), DateGroupEnum.Year, r("模式"))
ElseIf r("日期分组") = "月" Then
b.VGroups.AddDef(r("分组列"), DateGroupEnum.Month, r("模式"))
End If
ElseIf r.IsNull("日期分组")=False And r.IsNull("模式")=True Then
If r("日期分组") = "年" Then
b.VGroups.AddDef(r("分组列"), DateGroupEnum.Year )
ElseIf r("日期分组") = "月" Then
b.VGroups.AddDef(r("分组列"), DateGroupEnum.Month )
End If
ElseIf r.IsNull("日期分组")=True And r.IsNull("模式")=False Then
b.VGroups.AddDef( r("分组列"), r("模式"))
Else
b.VGroups.AddDef(r("分组列")) '添加列用于垂直分组
End If
End If
Next
''设置统计
For Each r As Row In Tables("统计3").Rows
If r.IsNull("统计列")=False Then
b.Totals.AddDef(r("统计列"), AggregateEnum.Count,r("标题")) '添加列用于统计
End If
Next
'
''设置统计选项
If e.Form.Controls("CheckBox1").Checked = True Then '水平方向生成汇总
b.HorizontalTotal = True
End If
If e.Form.Controls("CheckBox2").Checked = True Then '垂直方向生成汇总
b.VerticalTotal = True
b.Horiz
End If
If e.Form.Controls("CheckBox3").Checked = True Then '水平占比
b.HorizontalProportion=True
End If
If e.Form.Controls("CheckBox4").Checked = True Then '水平占比
b.OrderByTotal=True
End If
''获取统计条件
b.Filter=vars("filter")
'Tables("统计1").Select(-1,-1)
'b.Build '生成统计表
forms("窗口1").controls("Table1").Table.DataSource = b.BuildDataSource()
forms("窗口1").controls("Table1").Table.Select(-1,-1)
e.Form.Close
这次我填入分组列相关的,点击确定按钮时提示:未将对象引用到对象实例
麻烦老师了