一楼的代码看着好像也不对劲,这样试试:
If Forms("劳动报酬").Opened Then
Forms("劳动报酬").Controls("TextBox1").value = DataTables("劳动报酬").compute("Count([单位])","姓名 Is Not Null")
Select Case e.DataCol.Name
Case "评定等级"
If Forms("劳动报酬").Opened Then
Forms("劳动报酬").Controls("TextBox2").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'A'")
Forms("劳动报酬").Controls("TextBox3").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'B'")
Forms("劳动报酬").Controls("TextBox4").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'C'")
Forms("劳动报酬").Controls("TextBox5").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'D'")
End If
End Select
'百分比
Dim zc As Integer = CInt(Forms("劳动报酬").Controls("TextBox1").Value) '在册
If zc > 0 Then
Dim a As Integer = CInt(Forms("劳动报酬").Controls("TextBox2").Value) 'A
Dim b As Integer = CInt(Forms("劳动报酬").Controls("TextBox3").Value) 'B
Dim c As Integer = CInt(Forms("劳动报酬").Controls("TextBox4").Value) 'C
Dim d As Integer = CInt(Forms("劳动报酬").Controls("TextBox5").Value) 'D
Dim ab As Double = IIf(a=0,0,a/zc*100)
Dim bb As Double = IIf(b=0,0,b/zc*100)
Dim cb As Double = IIf(c=0,0,c/zc*100)
Dim db As Double = IIf(d=0,0,d/zc*100)
Forms("劳动报酬").Controls("TextBox6").Value = Math.Round(ab,2)
Forms("劳动报酬").Controls("TextBox7").Value = Math.Round(bb,2)
Forms("劳动报酬").Controls("TextBox8").Value = Math.Round(cb,2)
Forms("劳动报酬").Controls("TextBox9").Value = Math.Round(db,2)
End If
End If