有一些基本的语法错误:
Dim sql As String
Dim ny As String = Forms("数据载入").Controls("ComboBox1").Text
If ny = "请选择年月" Then
MessageBox.Show("请在右侧窗口选择报表年月","提示")
Return
End If
sql = "Select 报表年月,单位,投工类型,投工 FROM {日报源表} WHERE 报表年月= '" & ny & "' "
'根据临时表生成分类汇总表
Dim b As New CrossTableBuilder("年度汇总",sql,"SCGL")
b.HGroups.AddDef("单位")
b.VGroups.AddDef("投工类型")
b.Totals.AddDef("投工")
b.HorizontalTotal = True
b.VerticalTotal = True
b.Build()
Tables("当月投工分类").Cols("单位").TextAlign = TextAlignEnum.Center
Tables("当月投工分类").AutoSizeCols()
MainTable = Tables("当月投工分类") '打开生成的统计表