以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]复制附表及明细表闪退  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=126149)

--  作者:hahahehe21
--  发布时间:2018/10/15 16:21:00
--  [求助]复制附表及明细表闪退
窗口按钮想实现复制父表及三个子表,以下代码有时候能成功,有时候会闪退。
Dim r As Row = Tables("订单产品资料").Current
Dim dnew As Row = Tables("订单产品资料").AddNew
Dim name As String = r("PNum") & "_复件"
For Each c As Col In Tables("订单产品资料").Cols
    If c.Name = "PNum" Then
        dnew(c.Name) = name
    ElseIf c.Name <> "_Identify" Then
        dnew("Product") = r("Product")
        dnew("PCount") = r("PCount")
        dnew("CalUnit") = r("CalUnit")
        dnew("InDate") = r("InDate")
        dnew("Des") = r("Des")
        dnew("OrderNum") = r("OrderNum")
        dnew("ProductType") = r("ProductType")
        dnew("Price") = r("Price")
        dnew("ContractNum") = r("ContractNum")
        dnew("SumPrice") = r("SumPrice")
        dnew("BKY") = r("BKY")
        dnew("Customer") = r("Customer")
        dnew("Sales") = r("Sales")
        dnew("Maker") = r("Maker")
        dnew("PType") = r("PType")
    End If
Next

Dim drs As List(Of DataRow)
drs = r.DataRow.GetChildRows("明细1")
Dim rc As DataRow
For Each dr As DataRow In drs
    rc = dr.Clone
    rc("IDD") = dnew("IDD")
Next

Dim dr1s As List(Of DataRow)
dr1s = r.DataRow.GetChildRows("明细2")
Dim rc1 As DataRow
For Each dr1 As DataRow In dr1s
    rc1 = dr1.Clone
    rc1("IDD") = dnew("IDD")
Next

Dim dr2s As List(Of DataRow)
dr2s = r.DataRow.GetChildRows("明细3")
Dim rc2 As DataRow
For Each dr2 As DataRow In dr2s
    rc2 = dr2.Clone
    rc2("IDD") = dnew("IDD")
Next
[此贴子已经被作者于2018/10/15 16:22:09编辑过]

--  作者:有点甜
--  发布时间:2018/10/15 16:25:00
--  

如果闪退,就是你datacolchanged事件有代码影响

 

http://www.foxtable.com/webhelp/scr/1522.htm

 

不然,尝试暂停事件触发

 

http://www.foxtable.com/webhelp/scr/2218.htm