Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共11 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:[求助]请教关于查询功能 从 组合框 换成 复选组合框后 代码该怎么改!

1楼
gaoyong30000 发表于:2012/1/12 13:18:00

 

组合框源代码如下:(支持模糊查询的)

Dim Filter As String
With e.Form.Controls("CheckedComboBox3")
   If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售顾问 Like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("CheckedComboBox1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户来源 Like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("CheckedComboBox2")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "欲购车型 Like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("CheckedComboBox4")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "意向级别 Like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("DateTimePicker9")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "建档日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("DateTimePicker10")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "建档日期 <= #" & .Value & "#"
    End If
End With
Tables("销售意向客户进度管制").filter = filter

[此贴子已经被作者于2012-1-12 13:19:10编辑过]
2楼
狐狸爸爸 发表于:2012/1/12 16:11:00
Dim Filter As String
With e.Form.Controls("CheckedComboBox1")
    If .Value IsNot Nothing Then
        Dim parts() As String = .Text.Split(",")
        For Each part As String In parts
            If Filter >"" Then
                Filter = Filter & " Or "
            End If
            Filter = Filter &  "销售顾问 Like '*" & part & "*'"
        Next
    End If
End With
messagebox.show(filter)
3楼
gaoyong30000 发表于:2012/1/12 19:22:00

老大 你这个针对一个组合复选框 很不错  但是 我项目上 是多个组合复选框   复选框与复选框之间不是or  而是and             该怎么加啊?

 

 

4楼
gaoyong30000 发表于:2012/1/12 22:26:00

图片点击可在新窗口打开查看此主题相关图片如下:1.jpg
图片点击可在新窗口打开查看
5楼
狐狸爸爸 发表于:2012/1/13 8:58:00

自己之间用Or,相互之间用And:

 

Dim Filter As String

With e.Form.Controls("CheckedComboBox1")
    If .Value IsNot Nothing Then
        Filter = Filter & "("
        Dim parts() As String = .Text.Split(",")
        For Each part As String In parts
            If Filter >"" Then
                Filter = Filter & " Or "
            End If
            Filter = Filter &  "销售顾问 Like '*" & part & "*'"
        Next
        Filter = Filter & ")"
    End If
End With
With e.Form.Controls("CheckedComboBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "("
        Dim parts() As String = .Text.Split(",")
        For Each part As String In parts
            If Filter >"" Then
                Filter = Filter & " Or "
            End If
            Filter = Filter &  "客户 Like '*" & part & "*'"
        Next
        filter = Filter & ")"
    End If
End With
messagebox.show(filter)

6楼
gaoyong30000 发表于:2012/1/13 9:31:00

老大出错!!!


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

7楼
狐狸爸爸 发表于:2012/1/13 9:34:00

这种问题,应该自己可以解决:

 

MessageBox.Show(Filter)

 

 

看看生成的表达式是什么,就知道原因了:

 

 

Dim Filter As String
With e.Form.Controls("CheckedComboBox1")
    If .Value IsNot Nothing Then
        Filter = Filter & "("
        Dim parts() As String = .Text.Split(",")
        For i As Integer = 0 To parts.Length  - 1
            If i > 0  Then
                Filter = Filter & " Or "
            End If
            Filter = Filter &  "销售顾问 Like '*" & parts(i) & "*'"
        Next
        Filter = Filter & ")"
    End If
End With
With e.Form.Controls("CheckedComboBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "("
        Dim parts() As String = .Text.Split(",")
        For i As Integer = 0 To parts.Length  - 1
            If i > 0  Then
                Filter = Filter & " Or "
            End If
            Filter = Filter &  "客户 Like '*" & parts(i) & "*'"
        Next
        filter = Filter & ")"
    End If
End With
messagebox.show(filter)

[此贴子已经被作者于2012-1-13 9:36:01编辑过]
8楼
gaoyong30000 发表于:2012/1/13 13:26:00
多谢 搞定了~~~~~~~
9楼
老有所乐 发表于:2012/1/13 15:10:00

  请教贺老师,五楼代码中这句 “  Filter = Filter & "("   ”含义是什么

[此贴子已经被作者于2012-1-14 14:42:10编辑过]
10楼
狐狸爸爸 发表于:2012/1/13 15:18:00
以下是引用老有所乐在2012-1-13 15:10:00的发言:

  请教何老师,五楼代码中这句 “  Filter = Filter & "("   ”含义是什么

 

用:

 

messagebox.show(filter)

 

就知道原因是什么了。

共11 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03598 s, 2 queries.