以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 按条件引用代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=169975) |
||||
-- 作者:wangglby -- 发布时间:2021/7/8 8:07:00 -- 按条件引用代码 请教下这个代码怎么写:
点击按钮实现,在表B中查找表A中的编码,如果能查到,则把表B中与表A(表A表B列很多,大多数列名相同,各别的不同)中列名相同(序号列除外)的数据引用到表A中,如果查不到,则弹窗提示。谢谢
|
||||
-- 作者:y2287958 -- 发布时间:2021/7/8 8:23:00 -- Dim lst As new List(of String) For Each dr As DataRow In DataTables("表A").Select("编码 is not null and 编码 <> \'\'") Dim fdr As DataRow = DataTables("表B").find("编码=\'" & dr("编码") & "\'") If fdr IsNot Nothing Then For Each dc As DataCol In DataTables("表A").DataCols If DataTables("表B").DataCols.Contains(dc.name) AndAlso dc.name <> "序号" dr(dc.name) = fdr(dc.name) End If Next Else lst.add(dr("编码")) End If Next If lst.Count > 0 Dim s As String = String.join(vbcrlf,lst.ToArray) MessageBox.Show(s) End If |
||||
-- 作者:wangglby -- 发布时间:2021/7/8 8:39:00 -- 万分感谢 |
||||
-- 作者:wangglby -- 发布时间:2021/7/8 8:43:00 -- 再请教个代码,谢谢
|
||||
-- 作者:有点蓝 -- 发布时间:2021/7/8 9:12:00 --
|
||||
-- 作者:wangglby -- 发布时间:2021/7/8 9:23:00 -- 谢谢蓝版 |