Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparison Operators as Parameters

Status
Not open for further replies.

crogers111

Technical User
Jan 23, 2004
158
US
CR XI
SQL

Is it possible to allow a user to input a comparison operator as a parameter ?

For example I was hoping to have 2 parameters:

?Operator
?Threshold

For example a user could enter:
?Operator: <
?Threshold: 5000

or as another example:

?Operator: >=
?Threshold: 10000

my goal is to use the parameter input in a formula within the report.

For example:

@PaidThreshold
if {Data.AmountPaid} {?Operator} {?Threshold}
then
{Data.AmountPaid}
 
crogers111,

I am unsure if the manner in which you have presented above would work, but an idea that comes to mind is to have a text prompt with the words for the various "inequality" and "equality" signs and then use IF statements to determine which is used in the selection criteria.

I don't have Crystal Reports in front of me at the moment, but the following outlines what I am thinking would be a viable method.

Selection Criteria:
Code:
[blue]IF[/blue] {?Operator} = "Equals" [blue]THEN[/blue]
(
    {Table.AmountPaid} = {?Threshold}
) [blue]ELSE[/blue]
[blue]IF[/blue] {?Operator} = "Greater Than" [blue]THEN[/blue]
(
    {Table.AmountPaid} > {?Threshold}
) [blue]ELSE[/blue]
[blue]IF[/blue] {?Operator} = "Greater Than or Equal To" [blue]THEN[/blue]
(
    {Table.AmountPaid} >= {?Threshold}
) [blue]ELSE[/blue]
[green]etc etc etc[/green]

Hope this helps! Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
*lightbulb*

The choices could be the textual representation of each inequality, but the wording would ensure everyone selects the sign they mean (I tutor mathematics and know there are plenty of persons who get thier > & < 's mixed up)

If you used the signs in place of words, the code would look like

IF {?Operator} = "=" THEN
(
{Table.AmountPaid} = {?Threshold}
) ELSE
etc etc etc

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top