Foxtable(狐表)用户栏目专家坐堂 → 查询问题


  共有2614人关注过本帖树形打印复制链接

主题:查询问题

帅哥哟,离线,有人找我吗?
qq864729713
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:143 积分:992 威望:0 精华:0 注册:2013/3/27 9:51:00
查询问题  发帖心情 Post By:2014/5/9 15:10:00 [只看该作者]


如何把产品名称和类别连起来查询? 代码怎么改?
麻烦

Dim cpmc As WinForm.TextBox = e.Form.Controls("产品名称")
Dim lb As WinForm.ComboBox = e.Form.Controls("类别")
Dim pz As WinForm.ComboBox = e.Form.Controls("牌子")
Dim Filter As String
With e.Form.Controls("产品名称")
    If .Value IsNot Nothing Then
        Filter = "产品名称 like '*" & cpmc.text & "*'"
    End If
End With
With e.Form.Controls("类别")
    If .Value IsNot Nothing Then
          filter = "类别 ='" & lb.text & "'"
    End If
End With

With e.Form.Controls("牌子")
    If .Value IsNot Nothing Then
        Filter = "牌子 ='" & pz.text & "'"
    End If
End With
If Filter > "" Then
    Tables("产品明细表").Filter = Filter
End If


If Filter > "" Then
    e.Form.Controls("添加产品").Table.Filter = Filter
End If

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2014/5/9 16:08:00 [只看该作者]


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/5/9 16:21:00 [只看该作者]

Dim cpmc As WinForm.TextBox = e.Form.Controls("产品名称")
Dim lb As WinForm.ComboBox = e.Form.Controls("类别")
Dim pz As WinForm.ComboBox = e.Form.Controls("牌子")


Dim Filter As String = "1=1 "
With e.Form.Controls("产品名称")
    If .Value IsNot Nothing Then
        Filter &= " and 产品名称 like '*" & cpmc.text & "*'"
    End If
End With
With e.Form.Controls("类别")
    If .Value IsNot Nothing Then
        Filter &= " and 类别 ='" & lb.text & "'"
    End If
End With
With e.Form.Controls("牌子")
    If .Value IsNot Nothing Then
        Filter &= " and 牌子 ='" & pz.text & "'"
    End If
End With

If Filter > "" Then
    Tables("产品明细表").Filter = Filter
End If


If Filter > "" Then
    e.Form.Controls("添加产品").Table.Filter = Filter
End If
[此贴子已经被作者于2014-5-9 16:21:41编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
qq864729713
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:143 积分:992 威望:0 精华:0 注册:2013/3/27 9:51:00
  发帖心情 Post By:2014/5/9 20:40:00 [只看该作者]

以下是引用有点甜在2014-5-9 16:21:00的发言:

Dim cpmc As WinForm.TextBox = e.Form.Controls("产品名称")
Dim lb As WinForm.ComboBox = e.Form.Controls("类别")
Dim pz As WinForm.ComboBox = e.Form.Controls("牌子")


Dim Filter As String = "1=1 "
With e.Form.Controls("产品名称")
    If .Value IsNot Nothing Then
        Filter &= " and 产品名称 like '*" & cpmc.text & "*'"
    End If
End With
With e.Form.Controls("类别")
    If .Value IsNot Nothing Then
        Filter &= " and 类别 ='" & lb.text & "'"
    End If
End With
With e.Form.Controls("牌子")
    If .Value IsNot Nothing Then
        Filter &= " and 牌子 ='" & pz.text & "'"
    End If
End With

If Filter > "" Then
    Tables("产品明细表").Filter = Filter
End If


If Filter > "" Then
    e.Form.Controls("添加产品").Table.Filter = Filter
End If
[此贴子已经被作者于2014-5-9 16:21:41编辑过]

如果我加入牌子类别,这个代码需要怎么 就算产品名称和类别为一个查询, 牌子和牌子类别为一个查询 
Dim cpmc As WinForm.TextBox = e.Form.Controls("产品名称")
Dim lb As WinForm.ComboBox = e.Form.Controls("类别")
Dim pz As WinForm.ComboBox = e.Form.Controls("牌子")

Dim pzlb As WinForm.ComboBox = e.Form.Controls("牌子类别")

Dim Filter As String = "1=1"
With e.Form.Controls("产品名称")
    If .Value IsNot Nothing Then
        Filter &= " and 产品名称 like '*" & cpmc.text & "*'"
    End If
End With
With e.Form.Controls("类别")
    If .Value IsNot Nothing Then
        Filter &= " and 类别 ='" & lb.text & "'"
    End If
End With
With e.Form.Controls("牌子")
    If .Value IsNot Nothing Then
        Filter &= " and 牌子 ='" & pz.text & "'"
    End If
End With
With e.Form.Controls("牌子类别")
    If .Value IsNot Nothing Then
        Filter &= " and 牌子类别 ='" & pzlb.text & "'"
    End If
End With
If Filter > "" Then
    Tables("产品明细表").Filter = Filter
End If


If Filter > "" Then
    e.Form.Controls("添加产品").Table.Filter = Filter
End If
[此贴子已经被作者于2014-5-9 20:40:28编辑过]

 回到顶部