我在按钮的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类型
不知道是什么原因,望解答
谢谢!
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类型
不知道是什么原因,望解答
谢谢!
试试
str = "{table1.time}='" & format(DTPicker1.Value,"yyyy-mm-dd") & "'"
and {table1.time}<'" & format(DTPicker2.Value,"yyyy-mm-dd") & "'"
的确没报错报表中TIME字段正常显示时是这样的格式:"2003-10-10 0:00:00",数据库中存的是"2003-10-10"
str = "{table1.time}=#" & format(DTPicker1.Value,"yyyy-mm-dd") & "#"
and {table1.time}<#" & format(DTPicker2.Value,"yyyy-mm-dd") & "#"
我有个笔误
应该是str = "{table1.time}>'" & DTPicker1.Value & "'"
and {table1.time}<'" & DTPicker2.Value & "'"
而不是str = "{table1.time}='" & DTPicker1.Value & "'"
and {table1.time}<'" & DTPicker2.Value & "'" 大家再出出主意
报错:
error in formula <record_selection>
'{CONVERT(varchar(10),table1.time,120)}>‘2003’
this field name is not known 程序运行时我输入的是2003-12-1啊
?????
1.DTPicker1.Value 应该大于DTPicker2.Value
2.DTPicker1.Value的日期类型应该和数据库中相同。
1。DTPicker1.Value 应该不大于DTPicker2.Value
我用的是这个方法:
"'" & Year(DTPicker1.Value) & " /" & Month(DTPicker1.Value) & " / " & Day(DTPicker1.Value) & "'"谢谢大家的热情相助