Tuesday, July 19, 2011

Crystal Reports - various input paramaters

Here is a way to have multiple input parameters specified.
In each of the below scenarios, if no parm is specified for the field, its value is set to true. Otherwise the actual condition is evaluated returning the appropriate true or false. Then all of the parms are "ANDED" together to get whether a record is selected or not.


(
    if {?sDispositions} <> "" then
        {purchaseorders.sDisposition} in {?sDispositions}
    else
        true
)
and
(
    if {?sFrom} = "" then 
       true
    else
       Date({purchaseorders.dtLastUpdate}) >= Date({?sFrom})
)
and
(
    if {?sTo} = "" then 
       true
    else
       Date({purchaseorders.dtLastUpdate}) <= Date({?sTo})
)
and 
(
    if {?sServicers} = 0 then
        true
    else
        {purchaseorders.iServicer} in {?sServicers}
)

No comments:

Post a Comment