以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- [求助] (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=75996)
|
-- 作者:SMXTB
-- 发布时间:2015/10/19 16:34:00
-- [求助]
设计了一个查询窗体,有一个文本输入控件,和两个时间输入控件,文本控件是要求模糊条件,现在通过两段代码都能分别操作查询,但两个条件同时输入时,提示AND运算符前缺少操作数:请问代码在哪里错了?
Dim tbl As Table = Tables("查询_Table1") Dim txt As String = e.Form.Controls("TextBox1").TEXT If txt = "" Then tbl.Filter = " " Else txt = "\'%" & txt & "%\'" tbl.Filter = "XM Like " & txt & " Or TXRY Like " & txt End If
With e.Form.Controls("KS") If .Value IsNot Nothing Then If tbl.Filter >"" Then tbl.Filter = Filter & " And " End If tbl.Filter = Filter & "FSSJ >= #" & .Value & "#" End If End With With e.Form.Controls("JS") If .Value IsNot Nothing Then If tbl.Filter >"" Then tbl.Filter = Filter & " And " End If tbl.Filter = Filter & "FSSJ <= #" & .Value & "#" End If End With
|
-- 作者:大红袍
-- 发布时间:2015/10/19 16:37:00
--
Dim tbl As Table = Tables("查询_Table1") Dim txt As String = e.Form.Controls("TextBox1").TEXT If txt > "" Then txt = "\'%" & txt & "%\'" tbl.Filter = "(XM Like " & txt & " Or TXRY Like " & txt & ")" End If
With e.Form.Controls("KS") If .Value IsNot Nothing Then If tbl.Filter >"" Then tbl.Filter = Filter & " And " End If tbl.Filter = Filter & "FSSJ >= #" & .Value & "#" End If End With With e.Form.Controls("JS") If .Value IsNot Nothing Then If tbl.Filter >"" Then tbl.Filter = Filter & " And " End If tbl.Filter = Filter & "FSSJ <= #" & .Value & "#" End If End With
|
-- 作者:SMXTB
-- 发布时间:2015/10/19 17:04:00
--
还是不行,而且代码中这个Dim Filter As String 是不能少的,加上后运行,提示错误:
此主题相关图片如下:未命名.bmp

|
-- 作者:大红袍
-- 发布时间:2015/10/19 17:11:00
--
Dim filter As String = "" Dim tbl As Table = Tables("查询_Table1") Dim txt As String = e.Form.Controls("TextBox1").TEXT If txt > "" Then txt = "\'%" & txt & "%\'" Filter = "(XM Like " & txt & " Or TXRY Like " & txt & ")" End If
With e.Form.Controls("KS") If .Value IsNot Nothing Then If filter >"" Then filter = Filter & " And " End If filter = Filter & "FSSJ >= #" & .Value & "#" End If End With With e.Form.Controls("JS") If .Value IsNot Nothing Then If filter >"" Then filter = Filter & " And " End If filter = Filter & "FSSJ <= #" & .Value & "#" End If End With tbl.filter = filter
|
-- 作者:SMXTB
-- 发布时间:2015/10/19 17:16:00
--
问题解决,非常感谢!
|
-- 作者:SMXTB
-- 发布时间:2015/10/23 15:57:00
--
按上面的代码稍稍变了一下,查询字段来自两个文本控件,不知道如何用AND连接,可以组合多个文本筛选条件,下面的代码不知如何修改才能达到目的:
Dim filter As String = "" Dim txt As String = e.Form.Controls("TextBox1").TEXT If txt > "" Then Filter = Filter & " And "
txt = "\'%" & txt & "%\'" Filter = "部门名称 Like " & txt End If
Dim txt1 As String = e.Form.Controls("TextBox2").TEXT If txt1 > "" Then txt1 = "\'%" & txt1 & "%\'" Filter = "专业 Like " & txt1 End If
If Filter > "" Then Tables("机构").Filter = Filter End If
|
-- 作者:Hyphen
-- 发布时间:2015/10/23 16:22:00
--
Dim filter As String = "" Dim txt As String = e.Form.Controls("TextBox1").TEXT If txt > "" Then txt = "\'%" & txt & "%\'" Filter = "部门名称 Like " & txt End If
Dim txt1 As String = e.Form.Controls("TextBox2").TEXT If txt1 > "" Then txt1 = "\'%" & txt1 & "%\'" If Filter > "" Then Filter = Filter & " and 专业 Like " & txt1 Else Filter = "专业 Like " & txt1 End If End If
If Filter > "" Then Tables("机构").Filter = Filter End If
|