以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  组合查询  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=105156)

--  作者:裴保民
--  发布时间:2017/8/12 20:58:00
--  组合查询

Dim Filter As String=""
Dim khmcmhcz As WinForm.CheckBox = e.Form.Controls("kuhumohuchaxunCheckBox")
With e.Form.Controls("kehuxingmingTextBox2")
    If .Value IsNot Nothing Then
        If khmcmhcz.Checked Then
            Filter &= "客户姓名 like \'%" & .Value  & "%\'"
        Else
            Filter &= "客户姓名= \'" & .Value & "\'"
        End If
    End If
End With
Dim sfzhmhcz As WinForm.CheckBox = e.Form.Controls("shenfenzhengmohuchaxunCheckBox")
With e.Form.Controls("shenfenzhenghaoTextBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        If sfzhmhcz.Checked Then
            Filter &= "身份证号 Like \'%" & .Value  & "%\'"
        Else
            Filter &= "身份证号= \'" & .Value & "\'"
        End If
    End If
End With
With e.Form.Controls("kehuxingbieComboBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "性别= \'" & .Value & "\'"
    End If
End With
Dim sjmhcz As WinForm.CheckBox = e.Form.Controls("shoujimohuchaxunCheckBox")
With e.Form.Controls("shoujihaoTextBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        If sjmhcz.Checked Then
            Filter &="客户主手机号 like \'%" & .Value   & "%\' Or 第二手机号 like \'%" & .Value   & "%\' Or  第三手机号 Like \'%" & .Value   & "%\'"
        Else
            Filter &= "客户主手机号 = \'" & .Value & "\' Or 第二手机号= \'" & .Value & "\' Or 第三手机号 = \'" & .Value & "\'"
        End If
    End If
End With
Dim dzmhcz As WinForm.CheckBox = e.Form.Controls("dizhimohuchaxunCheckBox")
With e.Form.Controls("kehudizhiTextBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        If dzmhcz.Checked Then
            Filter &= "客户地址 like \'%" & .Value  & "%\'"
        Else
            Filter &= "客户地址= \'" & .Value & "\'"
        End If
    End If
End With
With e.Form.Controls("kehuleibieComboBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "客户类别= \'" & .Value & "\'"
    End If
End With
If Filter > "" Then
    Tables("客户资料").Filter = Filter
End If

 

这段代码哪错了运行后(我是手机号是模糊查询、再加上性别)性别怎么不筛选呀

 

 

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:客户入库程序.table


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

--  作者:有点甜
--  发布时间:2017/8/13 13:34:00
--  
With e.Form.Controls("shoujihaoTextBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        If sjmhcz.Checked Then
            Filter &="(iif(客户主手机号 is null, 1=2, 客户主手机号 Like \'%" & .Value   & "%\') Or iif(第二手机号 is null, 1=2, 第二手机号 like \'%" & .Value   & "%\') Or iif(第三手机号 is null, 1=2,第三手机号 Like \'%" & .Value   & "%\'))"
        Else
            Filter &="(iif(客户主手机号 is null, 1=2, 客户主手机号 =\'" & .Value   & "\') Or iif(第二手机号 is null, 1=2, 第二手机号 = \'" & .Value   & "\') Or iif(第三手机号 is null, 1=2,第三手机号 = \'" & .Value   & "\'))"
        End If
    End If
End With

--  作者:裴保民
--  发布时间:2017/8/13 14:04:00
--  

这个是组合查询

就这几句代码吗?

看懂了

[此贴子已经被作者于2017/8/13 14:06:52编辑过]

--  作者:有点甜
--  发布时间:2017/8/13 14:30:00
--  
把其中的一段修改即可。