以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- [求助]数据自动引用 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=105206)
|
-- 作者:乡里出城
-- 发布时间:2017/8/14 11:36:00
-- [求助]数据自动引用
此主题相关图片如下:表b.png

在表C DataColChanged 事件下写以下代码:
Dim str As String = e.DataRow("第一列") If e.DataCol.Name = "第一列" Then Dim dr As DataRow dr = DataTables("表B").Find("第四列 like \'" & str & "\'" ) If dr IsNot Nothing Then e.DataRow("第四列") = dr("第四列")
End If End If
或
Dim str As String = e.DataRow("第一列") If e.DataCol.Name = "第一列" Then Dim dr As DataRow dr = DataTables("表B").Find("第四列 like \'%" & str & "%\'" ) If dr IsNot Nothing Then e.DataRow("第四列") = dr("第四列") End If End If
都达不到要的效果
此主题相关图片如下:表c.png

当表C第一列有数据改变时,想变成图3的效果
此主题相关图片如下:图3.png

[此贴子已经被作者于2017/8/14 11:46:47编辑过]
|
-- 作者:notebook
-- 发布时间:2017/8/14 11:40:00
--
dr = DataTables("表B").Find("第四列 like \'%" & str & "%\'" )
|
-- 作者:乡里出城
-- 发布时间:2017/8/14 11:48:00
--
不行,这个写我也试过
结果是这个的
此主题相关图片如下:图4.png

|
-- 作者:有点甜
-- 发布时间:2017/8/14 11:56:00
--
Dim str As String = e.DataRow("第一列") If e.DataCol.Name = "第一列" Then For Each dr As DataRow In DataTables("表B").Select("第四列 is not null") If str.Contains(dr("第四列")) Then e.DataRow("第四列") = dr("第四列") Exit For End If Next End If
|
-- 作者:乡里出城
-- 发布时间:2017/8/14 11:59:00
--
谢谢!
|
-- 作者:乡里出城
-- 发布时间:2017/8/14 12:15:00
--
此主题相关图片如下:表5.png

如果(图5)表B的基础表是这样的,
应该如何写,同样有图6的效果,找不到表达的思路。
此主题相关图片如下:表6.png

|
-- 作者:有点甜
-- 发布时间:2017/8/14 14:31:00
--
Dim str As String = e.DataRow("第一列") If e.DataCol.Name = "第一列" Then For Each dr As DataRow In DataTables("表B").Select("第四列 is not null") Dim ary() As String = dr("第四列").split(",") For Each s As String In ary If str.Contains(s) Then e.DataRow("第四列") = dr("第四列") Exit For End If Next Next End If
|
-- 作者:乡里出城
-- 发布时间:2017/8/14 14:57:00
--
Dim str As String = e.DataRow("第一列") If e.DataCol.Name = "第一列" Then For Each dr As DataRow In DataTables("表B").Select("第四列 is not null") Dim ary() As String = dr("第四列").split(",") For Each s As String In ary If str.Contains(s) Then e.DataRow("第四列") = dr("第四列") Exit For End If Next Next End If
|
上面这句好像写得不对,执行后,如图
此主题相关图片如下:图7.png

|
-- 作者:乡里出城
-- 发布时间:2017/8/14 17:06:00
--
有点甜你好,下面红色的这个代码好像不对,如8楼的图,谢谢!
Dim str As String = e.DataRow("第一列") If e.DataCol.Name = "第一列" Then For Each dr As DataRow In DataTables("表B").Select("第四列 is not null") Dim ary() As String = dr("第四列").split(",") For Each s As String In ary If str.Contains(s) Then e.DataRow("第四列") = dr("第四列") Exit For End If Next Next End If
|
|
-- 作者:有点甜
-- 发布时间:2017/8/14 17:38:00
--
改成
e.DataRow("第四列") = s
|