当表A年月为201201至201203时,单位取值为1;年月为201204至201207时,单位取值为4;年月为201208至201209时;单位取值为8,年月为201209至201210时,单位取值为10。要达到上述要求,以下代码应该如何修改,请各位老师指教。谢谢!
'填充单位
Dim pr As DataRow
For Each dr1 As DataRow In DataTables("表A").DataRows
If dr1.IsNull("编号") Then
dr1("单位") = Nothing
Else
pr = DataTables("表B").Find("编号 = '" & dr1("编号") & "' And 年月 >= '" & dr1("年月") & "'")
If pr IsNot Nothing Then
dr1("单位") = pr("单位")
Else
dr1("单位") = Nothing
End If
End If
Next
[此贴子已经被作者于2013-1-24 19:38:24编辑过]