Foxtable(狐表)用户栏目专家坐堂 → [求助] 查询(筛选)代码如何设计


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

主题:[求助] 查询(筛选)代码如何设计

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/12/17 22:29:00 [显示全部帖子]

 查询语句不要这样写,要这样写

 

 http://www.foxtable.com/help/topics/1058.htm

 


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/12/17 23:20:00 [显示全部帖子]

 

Dim cc As WinForm.ComboBox = e.Form.Controls("车厂")
Dim cx As WinForm.ComboBox = e.Form.Controls("车型")
Dim pl As WinForm.TextBox = e.Form.Controls("排量")
Dim nf As WinForm.TextBox = e.Form.Controls("年份")

Dim filter As String = "1=1"
If cc.Text > "" Then
    filter &= " and 车厂 = '" & cc.Text & "'"
End If
If cx.Text > "" Then
    filter &= " and 车型 = '" & cx.Text & "' "
End If
If pl.Text > "" Then
    filter &= " and  排量 like '*" & pl.Text & "*' "
End If
If pl.Text > "" Then
    filter &= " and  适用年份 like '*" & nf.Text & "*'"
End If

Tables("车型资料表").Filter = filter

[此贴子已经被作者于2014-12-17 23:20:30编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/12/18 9:55:00 [显示全部帖子]

写错了

 

Dim cc As WinForm.ComboBox = e.Form.Controls("车厂")
Dim cx As WinForm.ComboBox = e.Form.Controls("车型")
Dim pl As WinForm.TextBox = e.Form.Controls("排量")
Dim nf As WinForm.TextBox = e.Form.Controls("年份")

Dim filter As String = "1=1"
If cc.Text > "" Then
    filter &= " and 车厂 = '" & cc.Text & "'"
End If
If cx.Text > "" Then
    filter &= " and 车型 = '" & cx.Text & "' "
End If
If pl.Text > "" Then|
    filter &= " and  排量 like '*" & pl.Text & "*' "
End If
If nf.Text > "" Then
    filter &= " and  适用年份 like '*" & nf.Text & "*'"
End If

Tables("车型资料表").Filter = filter


 回到顶部