以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  追加  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=157801)

--  作者:a272797388
--  发布时间:2020/10/29 15:24:00
--  追加
请问一下, 如果性别输入“男”, 该行会增加在同项目的表B里。(两表结构一样)
If e.DataCol.Name = "性别" Then
    If e.NewValue Is Nothing Then
        e.DataRow("第一列") = Nothing
        e.DataRow("第二列") = Nothing
        e.DataRow("第三列") = Nothing
        e.DataRow("第四列") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("表A").Find("[性别] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("第一列") = dr("第一列")
            e.DataRow("第二列") = dr("第二列")
            e.DataRow("第三列") = dr("第三列")
            e.DataRow("第四列") = dr("第四列")
        End If
    End If
End If
请问这样能行吗
图片点击可在新窗口打开查看此主题相关图片如下:3.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2020/10/29 15:33:00
--  
每次都新增一行数据?测试有什么问题?
--  作者:a272797388
--  发布时间:2020/10/29 15:38:00
--  你好
只要表A, 性别输入“男” , 表A的这行就同时也加在表B里。
--  作者:有点蓝
--  发布时间:2020/10/29 15:41:00
--  
代码放到表A

If e.DataCol.Name = "性别" Then
    If e.NewValue Is Nothing Then
        e.DataRow("第一列") = Nothing
        e.DataRow("第二列") = Nothing
        e.DataRow("第三列") = Nothing
        e.DataRow("第四列") = Nothing
    Elseif e.DataRow("性别")=“男”
        Dim dr As DataRow = DataTables("表B").addnew
        dr = DataTables("表B").Find("[性别] = \'" & e.NewValue & "\'")
            dr("第一列") = e.DataRow("第一列")
            其它自己补上
    End If
End If