以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]权限加载问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=184623)

--  作者:Cloud
--  发布时间:2022/12/17 10:24:00
--  [求助]权限加载问题
求大神指点:
      用户表有三列为用户名|公司|公司1|公司2,分析表有公司列:在分析表的公司列中分别填入用户表中的公司|公司1公司2的名称,在加载分析表时此用户有查看所有公司的权限代码如下:
Dim Filter As String
Filter = "公司 = \'" &  Tables("用户表").Current("公司") & "\'and 公司 = \'" &  Tables("用户表").Current("公司1") & "\'and 公司 = \'" &  Tables("用户表").Current("公司2") & "\'"
DataTables("分析表").LoadFilter = Filter
DataTables("分析表").Load()
打开窗口加载时只能加载名称为公司的行,不能加载名称为公司1和公司2的行。
同样的方式,查询时代码:
Dim khmc As WinForm.ComboBox = e.Form.Controls("客户名称")
DataTables("分析表").LoadFilter = "客户名称 like \'%" & khmc.text & "%\'and 公司 = \'" &  Tables("用户表").Current("公司") & "\'and 公司 = \'" &  Tables("用户表").Current("公司1") & "\'and 公司 = \'" &  Tables("用户表").Current("公司2") & "\'"
DataTables("分析表").Load()
查询时只能查询出名称为公司的行,不能查询出名称为公司1和公司2的行。
                                                                                               请大神指点一下,谢谢

--  作者:有点蓝
--  发布时间:2022/12/17 10:31:00
--  
and 改为 or:http://www.foxtable.com/webhelp/topics/0102.htm

Filter = "公司 = \'" &  Tables("用户表").Current("公司") & "\' or 公司 = \'" &  Tables("用户表").

--  作者:Cloud
--  发布时间:2022/12/17 11:01:00
--  
大神好:
    改好后加载 没问题了,查询不行
Dim khmc As WinForm.ComboBox = e.Form.Controls("客户名称")
DataTables("生产核价_款式主表").LoadFilter = "客户名称 like \'%" & khmc.text & "%\' and 生产工厂 = \'" &  Tables("用户表").Current("用户地区") & "\' or 生产工厂 = \'" &  Tables("用户表").Current("分公司") & "\'or 生产工厂 = \'" &  Tables("用户表").Current("分公司1") & "\'"
DataTables("生产核价_款式主表").Load()

--  作者:有点蓝
--  发布时间:2022/12/17 11:04:00
--  
看来还是没有认真看帮助

计算表达式值的时候,And 优先于 Or,可以使用括号组合表达式来强制改变优先级,例如:

([省籍] = \'湖南\' Or [省籍] = \'广东\') And [学历] = \'博士\'

表示省籍是湖南或者广东的博士。


--  作者:Cloud
--  发布时间:2022/12/17 12:04:00
--  
谢谢