Foxtable(狐表)用户栏目专家坐堂 → 代码建立副本关联


  共有1974人关注过本帖树形打印复制链接

主题:代码建立副本关联

帅哥哟,离线,有人找我吗?
woshiabc
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:160 积分:1214 威望:0 精华:0 注册:2015/7/1 17:35:00
代码建立副本关联  发帖心情 Post By:2016/5/6 10:14:00 [只看该作者]

 Dim t As Table = Tables("PharmacyBagWelling_Table2")
With Tables("PharmacyBagWelling_Table1")
    If .Current Is Nothing Then
        t.Filter = "False"
    Else
        t.Filter = "报价单编号 = " & .Current("报价单编号")
    End If
End With

我设置了一个窗口,有报价主档和报价明细两个副本表,想要他们建立关联(报价单编号),使得点击主档的某行记录,报价明细就显示,相应的报价单编号明细,上面的代码是写在窗口的afterload事件里,发现如果没有明细就会报错。 然后我改成下面这段代码,发现报价明细什么东西都没有,并且新增主档的时候,明细看不见
Dim t As Table = Tables("PharmacyBagWelling_Table2")
With Tables("PharmacyBagWelling_Table1")
    If .Current Is Nothing Then
        t.Filter = "False"
    Else
        For Each r As Row In Tables("PharmacyBagWelling_Table2")
            If r.DataRow("报价单编号") = .Current("报价单编号")
                t.Filter = "报价单编号 = " & .Current("报价单编号")
            Else
                t.Filter = "False"
            End If
        Next
    End If
End With


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/5/6 10:21:00 [只看该作者]

代码这样写

 

Dim t As Table = Tables("PharmacyBagWelling_Table2")
With Tables("PharmacyBagWelling_Table1")
    If .Current Is Nothing Then
        t.Filter = "False"
    Else
        t.Filter = "报价单编号 = '" & .Current("报价单编号") & "'"
    End If
End With


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/5/6 10:22:00 [只看该作者]

如果你新增行的时候不显示,那你就在DataRowAdded事件写代码

 

If Tables.Contains("PharmacyBagWelling_Table1") Then

    e.DataRow("报价单编号") = Tables("PharmacyBagWelling_Table1").Current("报价单编号 ")

End If


 回到顶部