以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  在表B中查找身份证相同行,并复制。  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=162791)

--  作者:a272797388
--  发布时间:2021/4/15 21:29:00
--  在表B中查找身份证相同行,并复制。

在表A的身份证号列输入一个身份证号,在表B中查找身份证号相同的行,如果查到的话,把该行相应地复制到表A(输入身份证的这行)。如果查不到,退出程序。

请问下面的命令如何修改?

 

If e.DataCol.Name = "身份证号" AndAlso e.DataRow("身份证号") = True Then

find ("身份证号=&e.DateRow("身份证号码"&\'\'\'\') IsNot Nothing Then
    Dim nma() As String = {"B1","B2","B3","B4"}
\'A表数据来源列
    Dim nmb() As String = {"A1"
,"A2","A3","A4"} \'B表数据接收列
    Dim dr As DataRow = DataTables("表A"
).AddNew
   
For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
   
Next
End
If

 

[此贴子已经被作者于2021/4/15 21:30:50编辑过]

--  作者:有点蓝
--  发布时间:2021/4/15 21:37:00
--  

 表A,datacolchanged事件

If e.DataCol.Name = "身份证号" andalso e.DateRow.isnull("身份证号码") = false Then

dim dr as datarow = DataTables("表B").find ("身份证号= \'" & e.DateRow("身份证号码") & "\'")

if dr isnot nothing then

    Dim nma() As String = {"B1","B2","B3","B4"\'A表数据来源列
    Dim nmb() As String = {"A1"
,"A2","A3","A4"} \'B表数据接收列
    
For i As Integer = 0 To nma.Length - 1
       
e.DataRow(nma(i)) = dr(nmb(i))

    Next

end if
End
 If


--  作者:a272797388
--  发布时间:2021/4/15 22:10:00
--  是哪里出了问题?

If e.DataCol.Name = "身份证号" AndAlso e.DataRow isnull("身份证号码") = False Then

Dim dr As DataRow = DataTables("表B").find ("身份证号= \'" & e.DateRow("身份证号码") & "\'")

If dr IsNot Nothing Then

    Dim nma() As String = {"B1","B2","B3","B4"} \'A表数据来源列
    Dim nmb() As String = {"A1","A2","A3","A4"} \'B表数据接收列
    For i As Integer = 0 To nma.Length - 1
        e.DataRow(nma(i)) = dr(nmb(i))

    Next

End If
End If


图片点击可在新窗口打开查看此主题相关图片如下:44.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2021/4/15 22:15:00
--  
If e.DataCol.Name = "身份证号" AndAlso e.DataRow.isnull("身份证号码") = False Then
--  作者:a272797388
--  发布时间:2021/4/15 22:32:00
--  还是不行呢

If e.DataCol.Name = "身份证号" AndAlso e.DataRow.isnull("身份证号码") = False Then

Dim dr As DataRow = DataTables("表B").find ("身份证号= \'" & e.DateRow("身份证号码") & "\'")

If dr IsNot Nothing Then

    Dim nma() As String = {"B1","B2","B3","B4"} \'A表数据来源列
    Dim nmb() As String = {"A1","A2","A3","A4"} \'B表数据接收列
    For i As Integer = 0 To nma.Length - 1
        e.DataRow(nma(i)) = dr(nmb(i))

    Next

End If
End If


图片点击可在新窗口打开查看此主题相关图片如下:301.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2021/4/15 22:43:00
--  
Dim dr As DataRow = DataTables("表B").find ("身份证号= \'" & e.DataRow ("身份证号码") & "\'")
--  作者:13315253800
--  发布时间:2021/4/16 17:00:00
--  
没实现复制B表身份证号相同的行,请老师指点
--  作者:有点蓝
--  发布时间:2021/4/16 17:05:00
--  
选中表A"身份证号"列,然后重置列:http://www.foxtable.com/webhelp/topics/1469.htm
--  作者:13315253800
--  发布时间:2021/4/16 17:13:00
--  
表A的结构是“身份证号”、“A1”、“A2”、“A3”、“A4”
表B的结构是“身份证号”、“B1”、“B2”、“B3”、“B4”
我在Adatacolchanged事件输入
If e.DataCol.Name = "身份证号" AndAlso e.DataRow.isnull("身份证号码") = False Then
Dim dr As DataRow = DataTables("表B").find ("身份证号= \'" & e.DataRow ("身份证号码") & "\'")
If dr IsNot Nothing Then

    Dim nma() As String = {"B1","B2","B3","B4"} \'A表数据来源列
    Dim nmb() As String = {"A1","A2","A3","A4"} \'B表数据接收列
    For i As Integer = 0 To nma.Length - 1
        e.DataRow(nma(i)) = dr(nmb(i))

    Next

End If
End If
后在表A中输入与表B相同的身份证号,表A没变化

--  作者:有点蓝
--  发布时间:2021/4/16 17:21:00
--  
请上传实例说明