str  =  "{table1.time}='"  &  DTPicker1.Value  &  "'"  
           and  {table1.time}<'"  &  DTPicker2.Value  &  "'"  此句有错,应该是
str  =  "{table1.time}>'"  &  DTPicker1.Value  &  "'
           and  {table1.time}<'"  &  DTPicker2.Value  &  "'"

解决方案 »

  1.   

    tonnyhe(快乐编程) : 我的贴子笔误:)应该是”大于号“
    但程序还是不执行报表数据项显示为空
      

  2.   

    试试:dim  str  as  string  
    str  =  "datediff(day,{table1.time},'"  &  DTPicker1.Value  &  "')=0"  
               and  datediff(day,{table1.time},'"  &  DTPicker2.Value  &  "')>0"  
    CrystalReport1.ReportFileName  =  "d:\table1.rpt"  
    CrystalReport1.SelectionFormula  =  str  
    CrystalReport1.Action  =  1
      

  3.   

    将DTPicker1.Value,DTPicker2.Value转换成table1.time一致的数据格式。
    即使同为DATATIME类型也会因为显示格式不同而无法查询到数据。
      

  4.   

    zjcxc(邹建) :
    运行程序后报错 error in formula <record_selection>
      str  =  "datediff(day,{table1.time},'2003-12-1')<0
               and  datediff(day,{table1.time},'2003-12-4'>0"  
    the remaining text does not appear to be part of the formula tiger201(你是风儿我是沙,编程不如种地瓜。) :即使同为DATATIME类型也会因为显示格式不同而无法查询到数据。如果出现你说的这种情况该如何解决
      

  5.   

    问题已解决
    我用的是这个
    "'" & Year(DTPicker1.Value) & " /" & Month(DTPicker1.Value) & " / " & Day(DTPicker1.Value) & "'"谢谢大家