If e.DataCol.Name = "料号" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("单价") = Nothing '那么清空此行单价列的内容
Elseif e.DataRow.isnull("单价")
Dim dr As DataRow
'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr = DataTables("父表名称").Find("[料号] = '" & e.NewValue & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
e.DataRow("单价") = dr("单价")
End If
End If
End If