以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]条件表达式中的这种包含如何写 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=148760) |
-- 作者:huangfanzi -- 发布时间:2020/4/14 22:45:00 -- [求助]条件表达式中的这种包含如何写 假定有个公司表,有条记录,其经营产品种类列中填入了 “A,B”,代表此公司同时经营A与B 二个产品 现在有个查询窗口,窗口中有个 CheckedComboBox控件,其下拉的内容有 A,B,C。。。 现在勾选 A与C,代表要查询经营A或C产品的公司 我现在希望能查到这家经营“A,B”的公司,因为此公司经营的产品中包含A,应被查询到 条件表达式应该如何写? 谢谢!
[此贴子已经被作者于2020/4/14 22:46:42编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/4/14 23:02:00 -- Dim s As String = "A,C" Dim filter As String = "1=2 " For Each s1 As String In s.split(",") filter = filter & " or \',\'+产品+\',\' like \'%," & s1 & ",%\' " Next Output.Show(filter)
|
-- 作者:huangfanzi -- 发布时间:2020/4/14 23:13:00 -- 老师,你的代码我看懂了,这是我下面改的,不知改的对不对,上班了,项目不在手边,无法测试 实际项目中,查询条件还有好几个,类别只是其中之一 Dim s as String = ccb类别.Text
Dim flt As String = "1=1" Dim filter As String = "1=2 " If ccb类别.Value = "全选" OrElse ccb类别.Value = "" Then flt = flt Else For Each s1 As String In s.split(",") filter = filter & " or \',\'+类别+\',\' like \'%," & s1 & ",%\' " Next flt = flt And "(" & filter & ")" End If [此贴子已经被作者于2020/4/15 8:21:01编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/4/15 8:29:00 -- Dim s As String = e.Form.Controls("CheckedComboBox_类别").Text Dim filter As String = "1=2 " If s = "全选" OrElse s = "" Then filter = "" else filter = "1=2 " For Each s1 As String In s.split(",") filter = filter & " or \',\'+类别+\',\' like \'%," & s1 & ",%\' " Next end if Output.Show(filter)
[此贴子已经被作者于2020/4/15 8:29:07编辑过]
|