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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case & Parameter Arrays

Status
Not open for further replies.

BuGlen

MIS
Jun 16, 2000
254
US
I'm having a bit of problem with the Select Case logical expression in my formula. I have several parameter parameter fields that return arrays of values (using the Allow Multiple Values option). I'm trying to assign a group name based on which parameter array the item is found. Here's my formula:
Code:
select {Users.swLogin}
    case {?Group1}[1] to {?Group1}[ubound({?Group1})] :
        "Group 1"
    case {?Group2}[1] to {?Group2}[ubound({?Group2})] :
        "Group 2"
    case {?Group3}[1] to {?Group3}[ubound({?Group3})] :
        "Group 3"
    default :
        "(Not Grouped)";

Logically, this should work, but the users do not match the groups assigned in the parameter fields. I can get this to work within an if/else if/else statement, but I was hoping to use the select case statement as an alternative.

Any help would be greatly appreciated.

- Glen
 
It appears that you're trying to assign a grouping based on items entered or selected by users.

If it's efficiencies you're after, I'd suggest a SQL Expression using case logic. This is database and Crystal version dependent, neither of which you've shared.

-k
 
The reason this doesn't logically work is that your case statement is saying return all values between the first parm value and the last for each parameter, so if, for example, {?Group1} selections are 1,3,5, your case statement would return {users.swlogin} from 1 to 5, not each instance of {?Group1}. Select case statements don't save that much coding time compared to if/then's. It would probably be as simple (or simpler) to use:

if {Users.swLogin} in {?Group1} then "Group1" else
if {Users.swLogin} in {?Group2} then "Group2" else
if {Users.swLogin} in {?Group3} then "Group3" else "Not Selected"

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top