在窗口1中删除关联表记录的代码如下:
Dim t As Table = Tables("表A.表B")
If t.GetCheckedRows.Count = 0
MessageBox.Show("请在复选框中选择要删除的行")
Else
If MessageBox.Show("是否要删除选择的记录行?","请确认",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
For Each r As Row In t.GetCheckedRows
r.Delete
Next
End If
End If
父表A的currentchanged 事件代码为:
If Forms("窗口1").Opened Then
Dim t As Table = Tables("表A")
If t.Current IsNot Nothing Then
For Each cl As Col In t.Cols
If Forms("窗口1").Controls.Contains(cl.name) Then
Forms("窗口1").Controls(cl.name).value= t.Current(cl.name)
End If
Next
End If
子表B和关联表表A.表B的currentchanged 事件代码为:
If Forms("窗口1").Opened Then
Dim t As Table = Tables("表A.表B")
If t.Current IsNot Nothing Then
For Each cl As Col In t.Cols
If Forms("窗口1").Controls.Contains(cl.name) Then
Forms("窗口1").Controls(cl.name).value= t.Current(cl.name)
End If
Next
End If
End If
关联表记录有两条以上记录时,删除正常。但如果关联表只有一条记录时,删除后显示错误如图所示。请老师指点下。
此主题相关图片如下:aaa.jpg