此主题相关图片如下:mysql-关联1.jpg

执行下面代码
Dim t2 As Table = Tables("MYSQL-01_Table2") '
With Tables("MYSQL-01_Table1") '
If .Current Is Nothing Then
t2.Filter = "False"
Else
t2.Filter = "sellID = '" & .Current("sellID") & "'"
End If
End With
执行上面代码,如图
此主题相关图片如下:mysql-关联2.jpg

这步,有以下问题:
问题一:执行下面代码
'表CurrentChanged
If Forms("MYSQL-01").Opened() Then'一定要判断用于模拟关联表的窗口是否已经打开
Dim t As Table = Tables("MYSQL-01_Table2")
With Tables("MYSQL-01_Table1")
If .Current Is Nothing Then
t.Filter = "False"
Else
' t.Filter = "tb_sell_main.sellID = '" & .Current("tb_sell_main.sellID") & "'"
t.Filter = "sellID = '" & .Current("sellID") & "'"
End If
End With
End If
报错找不到sellID,tb_sell_main.sellID
问题二,主表可新增行,但明细表则不能新增行,不为什么?
问题三:下面代码也没有作用
'6、将表的全局DataRowAdding事件代码设置为:
If CurrentTable.Name = "MYSQL-01_Table2" Then '如果当前表是模拟的关联表
' Dim r As Row = Tables("tb_sell_main").Current
Dim r As Row = Tables("MYSQL-01_Table1").Current
If r IsNot Nothing Then
e.DataRow("sellID") = r("sellID")
End If
End If