我使用这个公式参数(记录选择):
if {?customPort} <> "" then {ArrivingTrips.port} = {?customPort};
if {?airlin} <> "" then {ArrivingTrips.airlines} = {?airlin};
if {?hal} <> "" then {ArrivingTrips.hall}={?hal};
if (hasvalue({?tim})) then {ArrivingTrips.arrivalTime}={?tim};
{?d1} = {ArrivingTrips.arrivalDate};
现在的问题是,即使“if”表达式为真,水晶报告只是查看d1和dosent关注其他参数,因此它显示了不需要的数据,为什么呢?
语法错了吗?
注意:我通过我的vb.net代码发送参数值,而不是通过Crystal参数输入面板发送。
感谢。
答案 0 :(得分:1)
local timevar t;
local stringvar air;
local stringvar port;
local stringvar halll;
if {?tim} <> "" then t:= ctime({?tim}) else t:= ctime({ArrivingTrips.arrivalTime});
if {?airlin} <> "" then air:= {?airlin} else air:= {ArrivingTrips.airlines};
if {?customport} <> "" then port:= {?customPort} else port:= {ArrivingTrips.port};
if {?hal} <> "" then halll:= {?hal} else halll:= {ArrivingTrips.hall};
{ArrivingTrips.airlines} = air and {?d1}= {ArrivingTrips.arrivalDate} and port={ArrivingTrips.port} and halll = {ArrivingTrips.hall} and (t)=ctime({ArrivingTrips.arrivalTime});
这是解决方案,现在,当“if condition”返回false结果时,report将只关注真实条件,因为false将返回一个字段的相同值,所以它就像没有条件:)
感谢每个人都试图提供帮助。
答案 1 :(得分:0)
({?d1} = {ArrivingTrips.arrivalDate})
AND (If {?customPort} <> "" Then {ArrivingTrips.port} = {?customPort} Else TRUE)
AND (If {?airlin} <> "" Then {ArrivingTrips.airlines} = {?airlin} Else TRUE)
AND (If {?hal} <> "" Then {ArrivingTrips.hall}={?hal} Else TRUE)
AND (If (hasvalue({?tim})) Then {ArrivingTrips.arrivalTime}={?tim} Else TRUE)
答案 2 :(得分:0)
您正在将您的选择公式编写为单个语句,因此只评估行中的最后一个语句。对于每个“if”条件,您还应该有一个“else”,否则您的语句将容易出错并可能显示不需要的数据。
(if {?customPort} <> "" then {ArrivingTrips.port} = {?customPort} else {other.condition}) OR
(if {?airlin} <> "" then {ArrivingTrips.airlines} = {?airlin} else {other.condition}) OR
(if {?hal} <> "" then {ArrivingTrips.hall}={?hal} else {other.condition}) OR
(if (hasvalue({?tim})) then {ArrivingTrips.arrivalTime}={?tim} else {other.condition}) OR
({?d1} = {ArrivingTrips.arrivalDate})
此公式将评估是否满足任何条件。如果您需要满足条件组合,则必须使用AND加入它们。