以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 查询出来的记录不完整,请教各位老师 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81615) |
-- 作者:瑶蝶翩舞 -- 发布时间:2016/3/2 10:36:00 -- 查询出来的记录不完整,请教各位老师 此主题相关图片如下:11.png 老师们,请看,搜索“天津地铁7号线”,实际上记录有10个,搜索出来的只有4个 另外,按日期搜索,实际有8个2016年的记录,但是只搜索出来2个。 这是代码,老师们请看: Dim num As WinForm.TextBox = e.Form.Controls("文件编号") Dim pjsort As WinForm.ComboBox = e.Form.Controls("项目分类") Dim text As WinForm.TextBox = e.Form.Controls("文件内容") Dim zhye As WinForm.CheckedComboBox = e.Form.Controls("相关专业") Dim sort As WinForm.ComboBox = e.Form.Controls("文件类别") Dim company As WinForm.ComboBox = e.Form.Controls("发放单位") Dim linkman As WinForm.TextBox = e.Form.Controls("联系人") Dim jscompany As WinForm.CheckedComboBox = e.Form.Controls("接收单位") Dim StartDate As WinForm.DateTimePicker = e.Form.Controls("起始日期") Dim EndDate As WinForm.DateTimePicker = e.Form.Controls("终止日期") If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' " End If If Trim(pjsort.Text) IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\'" Else Tables("总表").Filter="项目分类 like \'*" & Trim(pjsort.Text) & "*\'" End If End If If Trim(text.Text) IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\' and 文件内容 like \'*" & Trim(text.Text) & "*\'" Else Tables("总表").Filter="文件内容 like \'*" & Trim(text.Text) & "*\'" End If End If If Trim(zhye.Text) IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\' and 文件内容 like \'*" & Trim(text.Text) & "*\' and 相关专业 like \'*" & Trim(zhye.Text) & "*\'" Else Tables("总表").Filter="相关专业 like \'*" & Trim(zhye.Text) & "*\'" End If End If If Trim(sort.Text) IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\' and 文件内容 like \'*" & Trim(text.Text) & "*\' and 相关专业 like \'*" & Trim(zhye.Text) & "*\' and 文件类别 like \'*" & Trim(sort.Text) & "*\'" Else Tables("总表").Filter="文件类别 like \'*" & Trim(sort.Text) & "*\'" End If End If If Trim(company.Text) IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\' and 文件内容 like \'*" & Trim(text.Text) & "*\' and 相关专业 like \'*" & Trim(zhye.Text) & "*\' and 文件类别 like \'*" & Trim(sort.Text) & "*\' and 发放单位 like \'*" & Trim(company.Text) & "*\'" Else Tables("总表").Filter="发放单位 like \'*" & Trim(company.Text) & "*\'" End If End If If Trim(linkman.Text) IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\' and 文件内容 like \'*" & Trim(text.Text) & "*\' and 相关专业 like \'*" & Trim(zhye.Text) & "*\' and 文件类别 like \'*" & Trim(sort.Text) & "*\' and 发放单位 like \'*" & Trim(company.Text) & "*\' and 联系人 like \'*" & Trim(linkman.Text) & "*\'" Else Tables("总表").Filter="联系人 like \'*" & Trim(linkman.Text) & "*\'" End If End If If Trim(jscompany.Text) IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\' and 文件内容 like \'*" & Trim(text.Text) & "*\' and 相关专业 like \'*" & Trim(zhye.Text) & "*\' and 文件类别 like \'*" & Trim(sort.Text) & "*\' and 发放单位 like \'*" & Trim(company.Text) & "*\' and 联系人 like \'*" & Trim(linkman.Text) & "*\' and 接收单位 like \'*" & Trim(jscompany.Text) & "*\'" Else Tables("总表").Filter="接收单位 like \'*" & Trim(jscompany.Text) & "*\'" End If End If If StartDate.value IsNot Nothing And EndDate.value IsNot Nothing Then If Tables("总表").Filter IsNot Nothing Then Tables("总表").Filter= "文件编号 like \'*" & Trim(num.Text) & "*\' and 项目分类 like \'*" & Trim(pjsort.Text) & "*\' and 文件内容 like \'*" & Trim(text.Text) & "*\' and 相关专业 like \'*" & Trim(zhye.Text) & "*\' and 文件类别 like \'*" & Trim(sort.Text) & "*\' and 发放单位 like \'*" & Trim(company.Text) & "*\' and 联系人 like \'*" & Trim(linkman.Text) & "*\' and 接收单位 like \'*" & Trim(jscompany.Text) & "*\' and 日期 >= #" & StartDate.value & "# And 日期 <= #" & EndDate.value & "#" Else Tables("总表").Filter="日期 >= #" & StartDate.value & "# And 日期 <= #" & EndDate.value & "#" End If End If |
-- 作者:大红袍 -- 发布时间:2016/3/2 10:39:00 -- 查询代码不是这样写的,这样不规范,而且会累死你。
你要这样写
http://www.foxtable.com/help/topics/1058.htm
|
-- 作者:瑶蝶翩舞 -- 发布时间:2016/3/2 11:21:00 -- 谢谢老师,代码已经修改好了,问题解决了 |