以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  表A与表B 匹配数据  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=72206)

--  作者:jerry_hwx
--  发布时间:2015/7/25 17:34:00
--  表A与表B 匹配数据

请问

表A有2列:流水号;员工号

表B有5列:流水号;员工号;体重;名字;部门

把满足表A与表B,流水号;员工号都相同的名字,填充到表A的第3列里面。

就是EXCEL的 VLOOKUP 功能。

谢谢


--  作者:blsu33
--  发布时间:2015/7/25 22:36:00
--  
建一个窗口为停靠类型 属于表A  建一个Button 控件 
Dim dr1 As DataRow
If DataTables("表a") IsNot Nothing And DataTables("表b") IsNot Nothing Then
    For Each dr As DataRow  In DataTables("表a").DataRows
        If dr("流水号") IsNot Nothing AndAlso dr("员工号") IsNot Nothing Then
            dr1=DataTables("表b").Find("流水号=\'"& dr("流水号") &"\' And 员工号=\'"& dr("员工号") &"\'")
            If dr1 IsNot Nothing Then
                dr("第3列")=dr1("名字")
            End If
        End If
    Next
End If

--  作者:大红袍
--  发布时间:2015/7/26 9:31:00
--  
Dim dr1 As DataRow
For Each dr As DataRow In DataTables("表a").DataRows
   
    dr1=DataTables("表b").Find("流水号=\'"& dr("流水号") & "\' And 员工号=\'" & dr("员工号") & "\'")
    If dr1 IsNot Nothing Then
        dr("第3列")=dr1("名字")
    Else
        dr("第3列")=Nothing
    End If
   
Next

--  作者:大红袍
--  发布时间:2015/7/26 9:32:00
--  

http://www.foxtable.com/help/topics/1451.htm