Foxtable(狐表)用户栏目专家坐堂 → [求助]查询窗口再问


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

主题:[求助]查询窗口再问

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


加好友 发短信
等级:童狐 帖子:209 积分:1607 威望:0 精华:0 注册:2012/9/7 20:24:00
[求助]查询窗口再问  发帖心情 Post By:2012/10/9 10:16:00 [显示全部帖子]

我根据使用帮助设计了个查询窗口,前段时间在前辈的指点下把代码改成从后台查询了,但是现在有两个新问题

1.我的查询窗口有好几个查询条件,我现在只能在“版号”条件从后台查询,如果所有条件都能从后台查询,代码怎么改?

2.以前我的查询都是模糊查询,但是改为后台查询后成了精确查询了,这种情况代码怎么改?

下面是我的窗口和代码:


图片点击可在新窗口打开查看此主题相关图片如下:查询.jpg
图片点击可在新窗口打开查看
Dim Filter As String
With e.Form.Controls("TextBH")
    If .Value IsNot Nothing Then
        Filter = "版号 like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("Textpm")
    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("Textkh")
    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("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "接稿日期>= #" & .Value & "#"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "接稿日期 <= #" & .Value & "#"
    End If
End With
If Filter > "" Then
DataTables("产品信息查询表").LoadFilter ="版号 = '" & e.Form.Controls("textbh").Value & "'"
    DataTables("产品信息查询表").Load
    Tables("产品信息查询表").Filter = Filter
End If

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


加好友 发短信
等级:童狐 帖子:209 积分:1607 威望:0 精华:0 注册:2012/9/7 20:24:00
  发帖心情 Post By:2012/10/9 10:47:00 [显示全部帖子]

我按照你的方法把代码改后,有新的问题,只能精确查询,不能模糊查询

这是精确查询的代码:

Dim Filter As String
With e.Form.Controls("TextBH")
    If .Value IsNot Nothing Then
        Filter = "版号 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("Textpm")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "品名 = '" & .Value & "'"
    End If
End With

DataTables("产品信息查询表").LoadFilter = Filter
DataTables("产品信息查询表").Load()

这是模糊查询的代码:

Dim Filter As String
With e.Form.Controls("TextBH")
    If .Value IsNot Nothing Then
        Filter = "版号 like '*" & .Value & "*'"
    End If
End With
With e.Form.Controls("Textpm")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "品名 like '*" & .Value & "*'"
    End If
End With

DataTables("产品信息查询表").LoadFilter = Filter
DataTables("产品信息查询表").Load()


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


加好友 发短信
等级:童狐 帖子:209 积分:1607 威望:0 精华:0 注册:2012/9/7 20:24:00
  发帖心情 Post By:2012/10/9 11:02:00 [显示全部帖子]

哦,原来是通配符用错了谢谢狐狸爸爸和lin_hailun

 回到顶部