以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助] 单选框筛选问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=83448)

--  作者:xiaoyuseo
--  发布时间:2016/4/9 11:03:00
--  [求助] 单选框筛选问题
进销存统计页面 希望输入搜索框的内容和切换单选框   窗口的table可以给出筛选的内容,求助高人,感激
窗口AfterLoad代码为:
Dim hcrk As new SQLJoinTableBuilder("入库明细查询","耗材_入库明细")
hcrk.C
hcrk.AddTable("耗材_入库明细","药品代码","门诊药房信息","代码")
hcrk.AddTable("耗材_入库明细","入库单号","耗材_入库单据","入库单号")
hcrk.AddExp("药品编号","代码")
hcrk.AddExp("名称","药品名")
hcrk.AddExp("类型","分类")
hcrk.AddCols("规格","单位","数量")
hcrk.AddExp("单价","{耗材_入库明细}.进价")
hcrk.AddExp("金额","数量*{耗材_入库明细}.进价")
hcrk.AddExp("厂家信息","{耗材_入库明细}.生产厂家")
hcrk.AddExp("单据编号","{耗材_入库明细}.入库单号")
hcrk.AddCols("入库日期","审核日期","审核人","入库方式")
hcrk.AddExp("入库仓库","仓库编号")
hcrk.AddCols("供应商")
hcrk.AddExp("备注","{耗材_入库明细}.备注")
hcrk.Build()
MainTable = Tables("入库明细查询")
\'Tables("耗材入库查询汇总_入库明细查询").Fill(hcrk.BuildSql,"zfrj",True)

查询点击事件为:
Dim Filter As String
With e.Form.Controls("ComboBox1")
    If .Value IsNot Nothing Then
        Filter = "入库仓库 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("ComboBox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "入库方式 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("ComboBox3")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "供应商 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("DateTimePicker1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "入库日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "入库日期 <= #" & .Value & "#"
    End If
End With
If e.Form.Controls("RadioButton1").Checked = True \' 如果点击状态选择了"按入库单"
    If Filter >"" Then
        Tables("入库单").Filter = Filter
    End If
End If
If e.Form.Controls("RadioButton2").Checked = True \' 如果点击状态选择了"按明细"
    If Filter >"" Then
        Tables("耗材入库查询汇总_入库明细查询").Filter = Filter
    End If
End If
If e.Form.Controls("RadioButton3").Checked = True \' 如果点击状态选择了"按明细汇总"
    If Filter >"" Then
       Tables("入库明细汇总").Filter = Filter
    End If
End If
If e.Form.Controls("RadioButton4").Checked = True \' 如果点击状态选择了"按供应商"
    If Filter >"" Then
      Tables("入库供应商").Filter = Filter
    End If
End If




此主题相关图片如下:qq截图20160409110106.png
按此在新窗口浏览图片
[此贴子已经被作者于2016/4/9 11:35:57编辑过]

--  作者:Hyphen
--  发布时间:2016/4/9 11:39:00
--  
具体什么问题,出什么错?

Dim Filter As String = "1=1 "
With e.Form.Controls("ComboBox1")
    If .Text IsNot Nothing Then
        Filter = Filter & " and 入库仓库 = \'" & .Text & "\'"
    End If
End With
With e.Form.Controls("ComboBox2")
    If .Text IsNot Nothing Then
        Filter = Filter & " and 入库方式 = \'" & .Text & "\'"
    End If
End With
With e.Form.Controls("ComboBox3")
    If .Text IsNot Nothing Then
        Filter = Filter & " and 供应商 = \'" & .Text & "\'"
    End If
End With
With e.Form.Controls("DateTimePicker1")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 入库日期 >= #" & .Text & "#"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 入库日期 <= #" & .Text & "#"
    End If
End With
If e.Form.Controls("RadioButton1").Checked = True \' 如果点击状态选择了"按入库单"
    Tables("入库单").Filter = Filter
End If
If e.Form.Controls("RadioButton2").Checked = True \' 如果点击状态选择了"按明细"
    Tables("耗材入库查询汇总_入库明细查询").Filter = Filter
End If
If e.Form.Controls("RadioButton3").Checked = True \' 如果点击状态选择了"按明细汇总"
    Tables("入库明细汇总").Filter = Filter
End If
If e.Form.Controls("RadioButton4").Checked = True \' 如果点击状态选择了"按供应商"
    Tables("入库供应商").Filter = Filter
End If

--  作者:xiaoyuseo
--  发布时间:2016/4/9 12:22:00
--  

点击查询  没有反映 


--  作者:Hyphen
--  发布时间:2016/4/9 14:27:00
--  
msgbox(Filter)看条件,核对这个条件有没有数据。

另外筛选的是主表,窗口表有对应主表吗