帮忙修改一下代码:
当跨表合计数 Sum()等于空值或0时计算就会出现转换类型错误。
If e.DataCol.Name = "所属部门" OrElse e.DataCol.Name = "所属编制" Then
Dim Filter As String = "[所属部门] = '" & e.DataRow("所属部门") & "' and [所属编制] = '" & e.DataRow("所属编制") & "'"
Dim Filter2 As String = "[所属编制] = '" & e.DataRow("所属编制") & "'"
Dim Filter3 As String = "[体制] = '" & e.DataRow("体制") & "'"
e.DataRow("人数") = DataTables("在职人员信息").Compute("Count(姓名)", Filter)
e.DataRow("基本基数") = DataTables("在职人员信息").Compute("Sum(基本基数)", Filter)
e.DataRow("补充基数") = DataTables("在职人员信息").Compute("Sum(补充基数)", Filter)
e.DataRow("基养个人") = DataTables("在职人员信息").Compute("Sum(个人_养老保险)", Filter)
e.DataRow("基医个人") = DataTables("在职人员信息").Compute("Sum(个人_医疗保险)", Filter)
e.DataRow("失业个人") = DataTables("在职人员信息").Compute("Sum(个人_失业保险)", Filter)
e.DataRow("年金个人") = DataTables("在职人员信息").Compute("Sum(个人_年金)", Filter)
e.DataRow("年金企业") = DataTables("在职人员信息").Compute("Sum(企业_年金)", Filter)
e.DataRow("基本公积金") = DataTables("在职人员信息").Compute("Sum(基本公积金企业)", Filter) + DataTables("在职人员信息").Compute("Sum(基本公积金个人)", Filter)
e.DataRow("补充公积金") = DataTables("在职人员信息").Compute("Sum(补充公积金企业)", Filter) + DataTables("在职人员信息").Compute("Sum(补充公积金个人)", Filter)
e.DataRow("统筹内") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter2) * DataTables("社保下达").Compute("Sum(其中养统内)", Filter2 ) +0.001,"#")
e.DataRow("统筹外") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter2) * DataTables("社保下达").Compute("Sum(统筹外)", Filter2 ) +0.001,"#")
e.DataRow("基养企业") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter3) * DataTables("社保下达").Compute("Sum(基养企业)", Filter3 ) , "0.00")
e.DataRow("基医企业") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter3) * DataTables("社保下达").Compute("Sum(基医企业)", Filter3 ) , "0.00")
e.DataRow("失保企业") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter3) * DataTables("社保下达").Compute("Sum(失业企业)", Filter3 ) , "0.00")
e.DataRow("工伤企业") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter3) * DataTables("社保下达").Compute("Sum(工伤保险)", Filter3 ) , "0.00")
e.DataRow("生育保险") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter3) * DataTables("社保下达").Compute("Sum(生育保险)", Filter3 ) , "0.00")
e.DataRow("补充医疗") = format(DataTables("在职人员信息").Compute("Sum(基本基数)", Filter) / DataTables("在职人员信息").Compute("Sum(基本基数)", Filter3) * DataTables("社保下达").Compute("Sum(补医合计)", Filter3 ) , "0.00")
End If