'自动根据父表当前行显示子表关联行
'调用方法 Functions.Execute("ChildFilter","子表所在窗口名","子表所在窗口中的表名","关联名")
If Forms(args(0)).Opened()
Dim re As relation=relations(args(2))
Dim pcls() As DataCol = re.parentcolumns
Dim ccls() As DataCol = re.childcolumns
Dim rr As Row =Tables(re.ParentTable.name).current
Dim flt As String="True"
If pcls.length>0 Then
For i As Integer=0 To pcls.length-1
flt=flt & " and " & ccls(i).name & "='" & rr(pcls(i).name) & "'"
Next
End If
Dim t As Table = Tables(args(1))
Dim t1 As Table = Tables(re.parenttable.name)
Dim r As Row = t1.current
If r Is Nothing Then
t.Filter = "False"
Else
t.Filter = flt
End If
End If
'新增子表行时,自动根据父表当前行更新子表相关行的关联字段
'调用方法 Functions.Execute("ChildRowAdding",e,"关联名")
Dim e As object =args(0)
Dim re As relation=relations(args(1))
Dim pcls() As DataCol = re.parentcolumns
Dim ccls() As DataCol = re.childcolumns
Dim rr As Row =Tables(re.ParentTable.name).current
Dim r As DataRow =e.DataRow
If r IsNot Nothing
If pcls.length>0 Then
For i As Integer=0 To pcls.length-1
r(ccls(i).name)=rr(pcls(i).name)
Next
End If
End If
[此贴子已经被作者于2012-12-22 15:38:29编辑过]