Foxtable(狐表)用户栏目专家坐堂 → [求助]我这个查询条件,怎么没有效果?帮忙看看怎么回事,谢谢


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

主题:[求助]我这个查询条件,怎么没有效果?帮忙看看怎么回事,谢谢

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


加好友 发短信
等级:三尾狐 帖子:681 积分:5332 威望:0 精华:0 注册:2011/12/26 20:43:00
[求助]我这个查询条件,怎么没有效果?帮忙看看怎么回事,谢谢  发帖心情 Post By:2014/2/27 14:18:00 [显示全部帖子]

用代码生成的表,SQLQuery类型,弄出来查询无效果,还是哪些地方写的有问题,高手帮忙改改,谢谢

 

Dim Filter As String
With e.Form.Controls("jieshou")
    If .Value IsNot Nothing Then
        Filter = "jieshoudanwei = '" & .Value & "'"
    End If
End With
With e.Form.Controls("laiyuan")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "laiyuanjing = '" & .Value & "'"
    End If
End With
With e.Form.Controls("danju")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "danjuzhuangtai = '" & .Value & "'"
    End If
End With
With e.Form.Controls("weixiu")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "weixiuzhuangtai = '" & .Value & "'"
    End If
End With
With e.Form.Controls("chanpin")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "chanpin_xinghao = '" & .Value & "'"
    End If
End With
With e.Form.Controls("jihao")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "jihao = '" & .Value & "'"
    End If
End With
If e.Form.Controls("sxriqi").Checked = True
    With e.Form.Controls("kai")
        If .Value IsNot Nothing Then
            If Filter >"" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "sx_riqi >= #" & .Value & "#"
        End If
    End With
    With e.Form.Controls("jieshu")
        If .Value IsNot Nothing Then
            If Filter >"" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "sx_riqi <= #" & .Value & "#"
        End If
    End With
    If e.Form.Controls("jieriqi").Checked = True
        With e.Form.Controls("kai")
            If .Value IsNot Nothing Then
                If Filter >"" Then
                    Filter = Filter & " And "
                End If
                Filter = Filter & "jieshouriqi >= #" & .Value & "#"
            End If
        End With
        With e.Form.Controls("jieshu")
            If .Value IsNot Nothing Then
                If Filter >"" Then
                    Filter = Filter & " And "
                End If
                Filter = Filter & "jieshouriqi <= #" & .Value & "#"
            End If
        End With
        If e.Form.Controls("pairiqi").Checked = True
            With e.Form.Controls("kai")
                If .Value IsNot Nothing Then
                    If Filter >"" Then
                        Filter = Filter & " And "
                    End If
                    Filter = Filter & "pai_riqi >= #" & .Value & "#"
                End If
            End With
            With e.Form.Controls("jieshu")
                If .Value IsNot Nothing Then
                    If Filter >"" Then
                        Filter = Filter & " And "
                    End If
                    Filter = Filter & "pai_riqi <= #" & .Value & "#"
                End If
            End With
            If e.Form.Controls("huiriqi").Checked = True
                With e.Form.Controls("kai")
                    If .Value IsNot Nothing Then
                        If Filter >"" Then
                            Filter = Filter & " And "
                        End If
                        Filter = Filter & "weixiuriqi >= #" & .Value & "#"
                    End If
                End With
                With e.Form.Controls("jieshu")
                    If .Value IsNot Nothing Then
                        If Filter >"" Then
                            Filter = Filter & " And "
                        End If
                        Filter = Filter & "weixiuriqi <= #" & .Value & "#"
                    End If
                End With
                If Filter > "" Then
                    Tables("信息追踪_table1").Filter = Filter
                End If
            End If
        End If
    End If
End If


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


加好友 发短信
等级:三尾狐 帖子:681 积分:5332 威望:0 精华:0 注册:2011/12/26 20:43:00
  发帖心情 Post By:2014/2/27 14:33:00 [显示全部帖子]

已经搞大半天了,也不提示错误,数据也不变化,所以贴出代码来求帮助了

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


加好友 发短信
等级:三尾狐 帖子:681 积分:5332 威望:0 精华:0 注册:2011/12/26 20:43:00
  发帖心情 Post By:2014/2/27 14:52:00 [显示全部帖子]

现在出提示了,每个条件都现实无法找到列

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


加好友 发短信
等级:三尾狐 帖子:681 积分:5332 威望:0 精华:0 注册:2011/12/26 20:43:00
  发帖心情 Post By:2014/2/27 15:05:00 [显示全部帖子]

MessageBox.show(Filter)会现实指出的条件,点确定后就会直接跳出来一个未找到列***,但是我很确定我的列是存在的,这个表我使用的是SQLQuery类型的,

 

每个指定的条件都会跳出相对应的列不存在

 

 


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

图片点击可在新窗口打开查看此主题相关图片如下:2.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2014-2-27 15:06:31编辑过]

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


加好友 发短信
等级:三尾狐 帖子:681 积分:5332 威望:0 精华:0 注册:2011/12/26 20:43:00
  发帖心情 Post By:2014/2/27 15:13:00 [显示全部帖子]

1.这是生成的表

Select  [bianhao_ID] As [编号],jieshoudanwei As [接收机构],jieshouren As [接收人],laiyuanjing As [来源机构],[sx_danwei] As [送修单位],[sx_ren] As [送修人],[sx_riqi] As [送修日期],[sx_wuliu] As [送修物流],[sx_wuliu_d] As [送修物流单号],jieshouriqi As [接收日期],[chanpin_xinghao] As [产品型号],pinpai As [品牌],chanpindalei As [产品大类],jixin As [机芯],jihao As [机号],chanpinleibie As [产品类别],zichanshuxing As [资产属性],baoxiuxingzhi As [保修性质],[gz_xianxiang] As [故障现象],beijianxinghao As [屏型号],chuchangriqi As [出厂日期],danjuzhuangtai As [单据状态],[pai_riqi] As [派工日期],[pai_ren] As [派工人],[wx_hj] As [维修环节],weixiuzhuangtai As [维修状态],[wx_ren] As [维修人],beizhu As [备注] From {Main_table}  order by bianhao_ID ASC

 

2.这是查询条件

Dim Filter As String
With e.Form.Controls("jieshou")
    If .Value IsNot Nothing Then
        Filter = "jieshoudanwei = '" & .Value & "'"
    End If
End With
With e.Form.Controls("laiyuan")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "laiyuanjing = '" & .Value & "'"
    End If
End With
With e.Form.Controls("danju")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "danjuzhuangtai = '" & .Value & "'"
    End If
End With
With e.Form.Controls("weixiu")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "weixiuzhuangtai = '" & .Value & "'"
    End If
End With
With e.Form.Controls("chanpin")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "chanpin_xinghao = '" & .Value & "'"
    End If
End With
With e.Form.Controls("jihao")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "jihao = '" & .Value & "'"
    End If
End With
If e.Form.Controls("sxriqi").Checked = True
    With e.Form.Controls("kai")
        If .Value IsNot Nothing Then
            If Filter >"" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "sx_riqi >= #" & .Value & "#"
        End If
    End With
End If
With e.Form.Controls("jieshu")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "sx_riqi <= #" & .Value & "#"
    End If
End With
If e.Form.Controls("jieriqi").Checked = True
    With e.Form.Controls("kai")
        If .Value IsNot Nothing Then
            If Filter >"" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "jieshouriqi >= #" & .Value & "#"
        End If
    End With
End If
With e.Form.Controls("jieshu")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "jieshouriqi <= #" & .Value & "#"
    End If
End With
If e.Form.Controls("pairiqi").Checked = True
    With e.Form.Controls("kai")
        If .Value IsNot Nothing Then
            If Filter >"" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "pai_riqi >= #" & .Value & "#"
        End If
    End With
End If
With e.Form.Controls("jieshu")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "pai_riqi <= #" & .Value & "#"
    End If
End With
If e.Form.Controls("huiriqi").Checked = True
    With e.Form.Controls("kai")
        If .Value IsNot Nothing Then
            If Filter >"" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "weixiuriqi >= #" & .Value & "#"
        End If
    End With
End If
With e.Form.Controls("jieshu")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "weixiuriqi <= #" & .Value & "#"
    End If
End With
If Filter > "" Then
    Tables("信息追踪_table1").Filter = Filter
End If

 

3.错误提示

在9楼

 

 


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


加好友 发短信
等级:三尾狐 帖子:681 积分:5332 威望:0 精华:0 注册:2011/12/26 20:43:00
  发帖心情 Post By:2014/2/27 15:24:00 [显示全部帖子]

真是这样的问题,之前没有理解清除,现在可以了,郁闷死我了,真是谢谢大家了


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


加好友 发短信
等级:三尾狐 帖子:681 积分:5332 威望:0 精华:0 注册:2011/12/26 20:43:00
  发帖心情 Post By:2014/2/27 15:44:00 [显示全部帖子]

这么简单啊,我试试

 回到顶部