以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- [求助]查询结果在窗口重新生成一个表 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=80770)
|
-- 作者:荟美绘姿
-- 发布时间:2016/1/31 22:55:00
-- [求助]查询结果在窗口重新生成一个表
窗口中有一个[查询]控件,其代码为:
Dim Filter As String With e.Form.Controls("TextBox1") If .Value IsNot Nothing Then Filter = "clxx_lphm = \'" & .Value & "\'" End If End With With e.Form.Controls("ComboBox1") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "clxx_cpys = \'" & .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 & "jbxx_jcsj >= #" & .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 & "jbxx_jcsj <= #" & .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 & "ajclqh_tijiaoqh = \'" & .Value & "\'" End If End With If Filter > "" Then Tables("ybchengxu").Filter = Filter End If
要求:按照上面的查询代码查到的结果重新生成一个新表在窗口内显示,显示的列名不跟“ybchengxu”表中的列名一样,列名由代码来指定(窗口的表不绑定任何表)
请问大侠们,这个代码应如何写,请指教,谢谢!
|
-- 作者:荟美绘姿
-- 发布时间:2016/1/31 23:15:00
--
没人回,我只能先自己顶起来
|
-- 作者:Hyphen
-- 发布时间:2016/2/1 9:07:00
--
参考:http://www.foxtable.com/help/topics/2017.htm
|
-- 作者:大红袍
-- 发布时间:2016/2/1 10:02:00
--
1、你不能在窗口里多加一个副本表?隐藏起来?
2、点击查询的时候,把副本表显示出来即可。
|
-- 作者:荟美绘姿
-- 发布时间:2016/2/1 14:58:00
--
e.Form.Controls("Table1").Visible = True Dim Filter As String With e.Form.Controls("TextBox1") If .Value IsNot Nothing Then Filter = "clxx_lphm = \'" & .Value & "\'" End If End With With e.Form.Controls("ComboBox1") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "clxx_cpys = \'" & .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 & "jbxx_jcsj >= #" & .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 & "jbxx_jcsj <= #" & .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 & "ajclqh_tijiaoqh = \'" & .Value & "\'" End If End With If Filter > "" Then Tables("ybchengxu").Filter = Filter End If
以上代码为什么只显示不做筛选,错在哪了,请大侠们帮看一下下
|
-- 作者:大红袍
-- 发布时间:2016/2/1 15:01:00
--
是不是你表名写错了啊?
Tables("窗口1_Table1").Filter = Filter
|
-- 作者:荟美绘姿
-- 发布时间:2016/2/1 15:04:00
--
我那个代码是写在窗口中的[查询]控件内的
在窗口控件内不能用,错误:局部变量“Filter"在声明之前产能被引用
[此贴子已经被作者于2016/2/1 15:07:45编辑过]
|
-- 作者:大红袍
-- 发布时间:2016/2/1 15:06:00
--
上传实例。
http://www.foxtable.com/help/topics/1906.htm
|
-- 作者:荟美绘姿
-- 发布时间:2016/2/1 15:11:00
--
OK了,谢谢
|