以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]把代码改为从后台筛选 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91714) |
|
-- 作者:qscwdvefb -- 发布时间:2016/10/17 15:07:00 -- [求助]把代码改为从后台筛选 Forms("退款记载结果").Open Dim filter1 As String = "" With e.Form.Controls("combobox1") If .Value IsNot Nothing Then filter1 = "[F5319]Like \'*" & .Value & "*\'" End If End With With e.Form.Controls("TextBox1") If .Value IsNot Nothing Then If filter1 > "" Then filter1 = filter1 & " And " End If filter1 = filter1 & "[F4384]Like \'*" & .Value & "*\'" End If End With With e.Form.Controls("TextBox2") If .Value IsNot Nothing Then If filter1 >"" Then filter1 = filter1 & " And " End If filter1 = filter1 & "[F4387] Like \'*" & .Value & "*\'" End If End With With e.Form.Controls("TextBox3") If .Value IsNot Nothing Then If filter1 >"" Then filter1 = filter1 & " And " End If filter1 = filter1 & "[F4419]Like \'*" & .Value & "*\'" End If End With Dim cal1 As WinForm.DateTimePicker = e.Form.Controls("datetimepicker1") Dim cal2 As WinForm.DateTimePicker = e.Form.Controls("datetimepicker2") If cal1.value IsNot Nothing And cal2.value IsNot Nothing Then If filter1 > "" Then filter1 = filter1 & " and" End If filter1 = filter1 & "[F4411] >= \'" & cal1.value & " \' and [F4411] <= \' " & cal2.value & "\'" End If If filter1 > "" Then filter1 = filter1 & " and" End If Forms("退款记载结果").Controls("Table1").Table.filter = filter1 & " [F4415]>0" Forms("退款记载结果").Controls("label2").Text = Forms("退款记载结果").Controls("Table1").Table.Compute("sum(F4415)") 请问这段代码怎么改使得是从后台(外部数据源)筛选出来的结果?
|
|
-- 作者:有点蓝 -- 发布时间:2016/10/17 15:39:00 -- ...... Forms("退款记载结果").Controls("Table1").Table.filter = filter1 & " [F4415]>0" 改为 Dim dt As DataTable = Forms("退款记载结果").Controls("Table1").Table.DataTable dt.LoadFilter = filter1 & " [F4415]>0" dt.Load |
|
-- 作者:qscwdvefb -- 发布时间:2016/10/17 16:05:00 -- 好像运行后原来的表消失了,关掉窗口表后怎么还原它? |
|
-- 作者:qscwdvefb -- 发布时间:2016/10/17 16:10:00 -- 哦,不对,我说错了,是原来的表都变成筛选结果了,怎么复原它? |
|
-- 作者:有点蓝 -- 发布时间:2016/10/17 16:34:00 -- datatables(源表名).LoadFilter ="" datatables(源表名).Load
|
|
-- 作者:qscwdvefb -- 发布时间:2016/10/17 16:37:00 -- 以下是引用有点蓝在2016/10/17 16:34:00的发言:
datatables(源表名).LoadFilter ="" datatables(源表名).Load 请问这段代码放在哪里?
|
|
-- 作者:有点蓝 -- 发布时间:2016/10/17 16:47:00 -- 窗口AfterClose事件 |
|
-- 作者:qscwdvefb -- 发布时间:2016/10/17 17:17:00 -- 前面那几段代码combobox、TextBox、filter1 With e.Form.Controls("combobox1") If .Value IsNot Nothing Then filter1 = "[F5319]Like \'*" & .Value & "*\'" End If End With 要改吗?为什么我在combobox或者TextBox控件上输入条件后查询出来什么都没有?
|
|
-- 作者:有点蓝 -- 发布时间:2016/10/17 17:23:00 --
|
|
-- 作者:qscwdvefb -- 发布时间:2016/10/17 17:52:00 -- 对啊,我已经加了,之前的问题解决了,现在这个问题是我在combobox、textbox1那些控件上增加filter1的内容,但是运行时好像filter1没有筛选出来。。。 |