以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]大神帮忙看下!  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=30486)

--  作者:sadfox
--  发布时间:2013/3/28 19:08:00
--  [求助]大神帮忙看下!
当表A"变动类型"列有内容发生变化的行自动移动到表B,表A则删除。 if e.datacol.name=" 变动类型"then If e.newvalue is or nothing then Dim r as row=tables("表B").addenw r("姓名")=e.datarow("姓名") r("编号")=e.datarow("编号") r("日期")=e.datarow("日期") e.datatables.delete Datatables.save End if End if 因为列太多,有没有简单的方法?或者全部列直接移到表B?
--  作者:czy
--  发布时间:2013/3/28 19:17:00
--  

如果表结构是一样的,可以这样

 

If e.DataCol.name=" 变动类型"then
    If e.newvalue Is Or Nothing Then
        Dim r As Row=Tables("表B").addenw
        For Each c As Col In Tables("表B").Cols
            r(c.name) = e.DataRow(c.name)
        Next
        e.DataTables.delete DataTables.save
    End If
End If


--  作者:sadfox
--  发布时间:2013/3/28 19:34:00
--  
如果表结构不一样呢了?谢谢,再写整的列子好吗?
--  作者:czy
--  发布时间:2013/3/28 19:40:00
--  

一个列一个列写也是个办法。

排除不一样的列也是个办法。


--  作者:sadfox
--  发布时间:2013/3/28 19:48:00
--  
一个一个写太多了。排除法不知道咋写啊!
--  作者:狐狸爸爸
--  发布时间:2013/3/29 11:50:00
--  

表结构不一样:

 

If e.DataCol.name=" 变动类型"then
    If e.newvalue Is Or Nothing Then
        Dim nma() As String = {"A1","A2","A3","A4"} \'A表数据来源列
        Dim nmb() As String = {"B1","B2","B3","B4"} \'B表数据接收列
        Dim dr As DataRow = DataTables("表B").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nmb(i)) = e.DataRow(nma(i))
        Next
    End If
End If