DataColChanged事件,写代码
Select Case e.DataCol.name
Case "姓名"
If e.NewValue = Nothing Then
e.DataRow("奖惩") = Nothing
Else
Dim filter As String = "姓名 = '" & e.NewValue & "'"
Dim frm As WinForm.Form = forms("窗口1")
If frm.Opened Then
If frm.Controls("DateTimePicker1").value <> Nothing Then
filter &= " and 时间 >= #" & frm.Controls("DateTimePicker1").value & "#"
End If
If frm.Controls("DateTimePicker2").value <> Nothing Then
filter &= " and 时间 <= #" & frm.Controls("DateTimePicker2").value & "#"
End If
End If
e.DataRow("奖惩") = DataTables("表B").Compute("sum(奖励分数)", filter) - DataTables("表B").Compute("sum(处罚分数)", filter)
End If
End Select