我在按钮的CLICK事件中加入如下代码.  
dim  str  as  string  
str  =  "{table1.time}='"  &  DTPicker1.Value  &  "'"  
           and  {table1.time}<'"  &  DTPicker2.Value  &  "'"  
CrystalReport1.ReportFileName  =  "d:\table1.rpt"  
CrystalReport1.SelectionFormula  =  str  
CrystalReport1.Action  =  1  
 
结果报表中什么都不显示(也就是未执行查询)  
数据库中time字段为DATATIME类型  
 
不知道是什么原因,望解答  
谢谢!

解决方案 »

  1.   

    如果没有报错,就可能是查询条件无效造成的
    试试
    str  =  "{table1.time}='"  &  format(DTPicker1.Value,"yyyy-mm-dd")  &  "'"  
               and  {table1.time}<'"  &  format(DTPicker2.Value,"yyyy-mm-dd")   &  "'"
      

  2.   

    还是不执行啊
    的确没报错报表中TIME字段正常显示时是这样的格式:"2003-10-10 0:00:00",数据库中存的是"2003-10-10"
      

  3.   

    Access数据库中这样
    str  =  "{table1.time}=#"  &  format(DTPicker1.Value,"yyyy-mm-dd")  &  "#"  
               and  {table1.time}<#"  &  format(DTPicker2.Value,"yyyy-mm-dd")   &  "#"
      

  4.   

    还是不行....
    我有个笔误
    应该是str  =  "{table1.time}>'"  &  DTPicker1.Value  &  "'"  
               and  {table1.time}<'"  &  DTPicker2.Value  &  "'"  
    而不是str  =  "{table1.time}='"  &  DTPicker1.Value  &  "'"  
               and  {table1.time}<'"  &  DTPicker2.Value  &  "'"  大家再出出主意
      

  5.   

    试试CONVERT(varchar(10),table1.time,120)
      

  6.   

    CONVERT(varchar(10),table1.time,120)也不行啊
    报错:
    error in formula <record_selection>
    '{CONVERT(varchar(10),table1.time,120)}>‘2003’
    this field name is not known 程序运行时我输入的是2003-12-1啊
    ?????
      

  7.   

    注意:
    1.DTPicker1.Value 应该大于DTPicker2.Value 
    2.DTPicker1.Value的日期类型应该和数据库中相同。
      

  8.   

    不好意思,我写错了
    1。DTPicker1.Value 应该不大于DTPicker2.Value
      

  9.   

    问题已解决
    我用的是这个方法:
    "'" & Year(DTPicker1.Value) & " /" & Month(DTPicker1.Value) & " / " & Day(DTPicker1.Value) & "'"谢谢大家的热情相助