以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  窗口复合查询代码问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=97490)

--  作者:feixianzhi
--  发布时间:2017/3/13 15:11:00
--  窗口复合查询代码问题


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20170313150059_看图王.png
图片点击可在新窗口打开查看

 

现在默认的是按商品名称查询批发表和入库表,我想实现:当商品单价被选中时,那么按商品名称+商品单价查询;当商品单价、供应商名称选中时,那么就按商品名称+商品单价+供应商名称查询。依此类推,请各位老师帮忙,代码怎么写。

 


--  作者:feixianzhi
--  发布时间:2017/3/13 15:31:00
--  

请有点蓝老师帮忙呀。


--  作者:有点蓝
--  发布时间:2017/3/13 16:26:00
--  

if e.form.controls("商品单价").checked = true

\'拼凑按商品名称+商品单价查询的条件

elseif if e.form.controls("供应商名称").checked = true

\'拼凑按商品名称+商品单价+供应商名称的条件

......

 

拼凑条件参考:http://www.foxtable.com/webhelp/scr/1058.htm

 


--  作者:feixianzhi
--  发布时间:2017/3/13 16:32:00
--  

有点蓝老师,代码放哪里呀。


--  作者:feixianzhi
--  发布时间:2017/3/13 16:53:00
--  


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

 

有点蓝老师,我改了一下,把复选框去掉了,做了一个按钮,按钮代码如下:

 

Dim Filter As String
With e.Form.Controls("TextBox商品名称")
    If .Value IsNot Nothing Then
        Filter = "商品名称 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox客户名称")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "TextBox客户名称 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox进价")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "TextBox进价 = \'" & .Value & "\'"
    End If
End With

 

但我点按钮,批发表和入库表均没有反应,是代码有问题吧,请老师帮忙。


--  作者:有点蓝
--  发布时间:2017/3/13 17:21:00
--  

 Filter = Filter & "客户名称 = \'" & .Value & "\'"

 

Filter = Filter & "进价 = \'" & .Value & "\'"


筛选的条件里使用的是列名,不是控件名称


--  作者:feixianzhi
--  发布时间:2017/3/13 22:55:00
--  
Dim Filter As String
With e.Form.Controls("TextBox商品名称")
    If .Value IsNot Nothing Then
        Filter = "商品名称 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox客户名称")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户名称 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("TextBox进价")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "进价 = \'" & .Value & "\'"
    End If
End With


有点蓝老师,我把代码改成这样,还是没有反应,是不是需要指定哪个表呀。

--  作者:feixianzhi
--  发布时间:2017/3/14 7:41:00
--  

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目2.rar

 

 


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

 

有点蓝老师,我想实现:商品编码、供应商编码、客户编码、进价、单据开始日期、单据结束日期,这六个条件,任意输入,则点筛选按钮,则入库表和批发表同时按相关条件进行筛选。

 

我写了按钮代码,但没有反应,不知道错在哪里,请有点蓝老师帮忙。代码如下:

 

Dim Filter As String
With e.Form.Controls("商品编码")
    If .Value IsNot Nothing Then
        Filter = Filter &  "商品编码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("供应商编码")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "供应商编码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("进价")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "进价 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("客户编码")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户编码 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("单据开始日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "单据日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("单据结束日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "单据日期 <= #" & .Value & "#"
    End If
End With


--  作者:有点蓝
--  发布时间:2017/3/14 8:55:00
--  

既然知道要指定表,那就指定测试一下就知道咯

 

e.Form.Controls("批发表").Table.Filter = Filter


--  作者:feixianzhi
--  发布时间:2017/3/14 10:36:00
--  
有点蓝老师,这个代码放在哪呀。