以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]查询命令错误 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=53375) |
-- 作者:wumingrong1 -- 发布时间:2014/7/6 18:35:00 -- [求助]查询命令错误 我有一个查询窗口、查询按钮命令如下。可是我在其中一个文本框中已经录入了查询条件、但是为什么还是提示要输入内容? Dim flt As String For Each c As Col In Tables("地线测试登记表").Cols For Each ctl As WinForm.Control In e.Form.Controls If c.Name = ctl.Name Then If e.Form.Controls(ctl.Name).Text > "" Then If c.IsDate Then flt + = " And " & c.Name & " = #" & e.Form.Controls(ctl.Name).Text & "#" ElseIf c.IsString Then flt + = " And " & c.Name & " Like \'%" & e.Form.Controls(ctl.Name).Text & "%\'" End If End If End If Next Next If flt > "" Then flt = flt.SubString(5) Else MessageBox.Show("请输入查询条件") End If Tables("地线测试登记表").Filter = flt |
-- 作者:有点甜 -- 发布时间:2014/7/6 19:02:00 --
[此贴子已经被作者于2014-7-6 19:02:00编辑过]
|
-- 作者:有点甜 -- 发布时间:2014/7/6 19:04:00 -- Dim flt As String = "1=1" Dim flag As Boolean = False For Each c As Col In Tables("地线测试登记表").Cols For Each ctl As WinForm.Control In e.Form.Controls If c.Name = ctl.Name Then If e.Form.Controls(ctl.Name).Text > "" Then flag = True If c.IsDate Then flt &= " And " & c.Name & " = #" & e.Form.Controls(ctl.Name).Text & "#" ElseIf c.IsString Then flt &= " And " & c.Name & " Like \'%" & e.Form.Controls(ctl.Name).Text & "%\'" End If End If End If Next Next If flag Then Tables("地线测试登记表").Filter = flt Else MessageBox.Show("请输入查询条件") End If |
-- 作者:wumingrong1 -- 发布时间:2014/7/6 20:36:00 -- 改了、还是和1楼一样的 |
-- 作者:有点甜 -- 发布时间:2014/7/6 20:37:00 -- 如果这样,就是你给控件的命名不正确,你的控件的命名,必须和列名是一样的才行。 |