修改代码
Select Case e.DataCol.Name
Case "名称","月期"
If e.DataRow.IsNull("名称") = False AndAlso e.DataRow.IsNull("月期") = False Then
Dim d As Date = e.DataRow("月期")
Dim fd As Date = new Date(d.Year,d.Month,1)
Dim ld As Date = fd.AddMonths(1)
Dim filter As String = "名称='" & e.DataRow("名称") & "' and 日期 >= #" & fd & "# and 日期 < #" & ld & "#"
e.DataRow("发电总量") = DataTables("电站录入").Compute("Sum(日发电)","名称='" & e.DataRow("名称") & "'")
e.DataRow("月发电量") = DataTables("电站录入").Compute("Sum(日发电)", filter)
e.DataRow("当月发电天数") = DataTables("电站录入").GetValues("日期", filter).count
e.DataRow("当月最高发电量") = DataTables("电站录入").Compute("max(日发电)", filter)
If e.DataRow("当月发电天数") > 0 Then
e.DataRow("月均发电量") = e.DataRow("月发电量") / e.DataRow("当月发电天数")
End If
Dim fdr = DataTables("电站录入").find(filter, "日发电 desc")
If fdr IsNot Nothing Then
e.DataRow("当月最高发电日期") = fdr("日期")
Else
e.DataRow("当月最高发电日期") = Nothing
End If
End If
End Select