以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教一下这个情况怎么写find  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=82124)

--  作者:李睿涵
--  发布时间:2016/3/11 20:47:00
--  请教一下这个情况怎么写find
表A里填写了地址信息,表B里记录了片区及对应的片区代号
我选择了表A的某个地址,希望能在表B里查到地址中所含片区对应的片区代号
不知该怎么写代码,因为like不适用了。

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


--  作者:狐狸爸爸
--  发布时间:2016/3/11 23:18:00
--  

要么建立关联,通过表达式引用:
http://www.foxtable.com/help/topics/0106.htm

 


要么用代码:
http://www.foxtable.com/help/topics/1458.htm

在代码中用Find查找包括指定字符的行的时候,一样可以在查找条件表达式中用Like,参考:
http://www.foxtable.com/help/topics/0102.htm

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


 


--  作者:李睿涵
--  发布时间:2016/3/12 0:15:00
--  

Dim r As Row = Tables("表A").Current
Dim dr As DataRow = DataTables("表B").Find("片区 like \'*" & r("地址") & "*\'")
If dr IsNot Nothing Then
    msgbox(dr("片区代号"))
End If

 

上述代码无效


--  作者:Hyphen
--  发布时间:2016/3/12 9:03:00
--  
Dim r As Row = Tables("表A").Current
Dim dr As DataRow = DataTables("表B").Find("\'" & r("地址") & "\' Like  IIF([片区] is null,\'\',\'%\'+[片区]+\'%\')")
If dr IsNot Nothing Then
    msgbox(dr("片区代号"))
End If

试试上面这个,Access测试可以

--  作者:李睿涵
--  发布时间:2016/3/12 10:43:00
--  

acc里测试ok

我是sql数据源,测试不行:有值,但不弹出片区代号

 

我代码是:

 

Dim r As Row = Tables("表A").Current
Dim dr As DataRow = DataTables("表B").sqlFind("\'" & r("地址") & "\' Like  IIF([片区] is null,\'\',\'%\'+[片区]+\'%\')")
If dr IsNot Nothing Then
    msgbox(dr("片区代号"))
End If

 


--  作者:Hyphen
--  发布时间:2016/3/12 11:45:00
--  
Dim r As Row = Tables("表A").Current
Dim dr As DataRow = DataTables("表B").sqlFind("\'" & r("地址") & "\' Like  \'%\'+[片区]+\'%\'")
If dr IsNot Nothing Then
    msgbox(dr("片区代号"))
End If

--  作者:李睿涵
--  发布时间:2016/3/12 13:09:00
--  
好用,谢谢!