这个没有理由不可以的哦,从表1的DatacolChanged事件:
If e.DataCol.name = "姓名" Then
Dim dr1 As DataRow
Dim dr2 As DataRow
Dim dr3 As DataRow
dr1 = DataTables("主表1").Find("id1 = '" & e.DataRow("id1") & "'")
If dr1 IsNot Nothing Then
Dim y As Integer = e.DataRow("年份")
Dim m As Integer = e.DataRow("月份")
If m =1 Then
y = y -1
m = 12
Else
m = m -1
End If
dr2 = DataTables("主表2").Find("姓名 = '" & e.DataRow("姓名") & "' And 年份 = " & y & " and 月份 = " & m)
If dr2 IsNot Nothing Then
dr3 = DataTables("从表2").Find("id2 = '" & dr2("id2") & "'")
If dr3 IsNot Nothing Then
e.DataRow("上月出勤天数") = dr3("出勤数")
End If
End If
End If
End If