100分!请问一个关于access中某时间段内相关内容查询的问题(100分)

  • 主题发起人 主题发起人 hedana1977
  • 开始时间 开始时间
H

hedana1977

Unregistered / Unconfirmed
GUEST, unregistred user!
该功能的作用就是搜索出某时间段内某个产品是否返修的记录
tongji(表名) access数据库
表主要字段 编号(系统自动) 数量 品名 出货日期 返修状态(是/否)
ctime1(起始时间) ctime2(结束时间)
我现在想实现的功能就是 搜索出出货日期在ctime1和ctime2时间段内已经反修了的某个产品。
edit1(输入要搜索的品名) checkbox1 (选中是否返修) 这是已经建立的2个控件。

if dsset_b.Active then dsset_b.Close ;
dsset_b.CommandText := format('select * from tongji where 出货日期 between #%s# and #%s#',[DateToStr(time1.Date),DateToStr(time2.Date)]);
dsset_b.Open ;
这个代码是我写的搜索2个时间段内的所有产品的数据,测试正确。
求高手帮我把其他的要完成的内容补充一下,应该怎么写,我水平有限,谢谢帮忙!请尽量完整详细。
 
if dsset_b.Active then dsset_b.Close ;
if checkbox1 then
dsset_b.CommandText := format('select * from tongji where (出货日期 between #%s# and #%s#)and(返修状态=true)',[DateToStr(time1.Date),DateToStr(time2.Date)])
else
dsset_b.CommandText := format('select * from tongji where (出货日期 between #%s# and #%s#)and(返修状态=false)',[DateToStr(time1.Date),DateToStr(time2.Date)]);
dsset_b.Open ;
 
还有一项 edit1(输入要搜索的品名)
这个条件没有加进去呀,其他都调试正确,谢谢兄弟,弄完分都给你。
 
高手们,帮帮我呀
 
var
str:string;
begin
str:='';
if trim(edit1.text)<>'' then
str:=' and 品名 like ''%'+trim(edit1.text)+'%''';
if dsset_b.Active then dsset_b.Close ;
if checkbox1 then
dsset_b.CommandText := format('select * from tongji where (出货日期 between #%s# and #%s#)and(返修状态=true)'+str,[DateToStr(time1.Date),DateToStr(time2.Date)])
else
dsset_b.CommandText := format('select * from tongji where(出货日期 between #%s# and #%s#)and(返修状态=false)'+str,[DateToStr(time1.Date),DateToStr(time2.Date)]);
dsset_b.Open ;
end;
 
多人接受答案了。
 
后退
顶部