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

Multiple If Statements in the Record Selection Formula 1

Status
Not open for further replies.

lynchg

Programmer
Nov 5, 2003
347
US
Is it possible to have completely independent If statements in one record selection formula?

I am using Crystal 11.5 with a SQL Server 2000 database using ODBC. The datasource for the report is several SQL Server tables, and 4 crystal commands that create lists of values for the parameters, the users will make their parameter choices by selecting from drop-downs.

I have a series of parameters that I want the users to be able to select, and they should be completely independent choices, but it seems like the formula editor is forcing me to nest them.

Here is an example:

IF {?DeptName} = '...All' THEN TRUE
ELSE {SR_TEAM.DEPT_NAME} = {?DeptName}
AND
IF {?Type} = '...All' THEN TRUE
ELSE {RQST.RQST_TYPE_VLU} = {?Type}
AND
IF {?HandlingType} = '...All' THEN TRUE
ELSE {RQST.SPCL_HNDL_TYPE_VLU} = {?HandlingType}
AND
IF {?Region} = '...All' THEN TRUE
ELSE {RQST.LOC_VLU} = {?Region}

This formula doesn't do what I want, if the user chooses '...All' for the DeptName parameter then none of the others even get evaluated. I can't see how Else If's would work, that would treat them as being interdependent as well. I have considered a Select Case, but I am not sure that would work either.

My kingdom for an 'End If'! :)
 
Hi,
As a first pass, try using parens to clearly separate the
criteria:
Code:
(
IF {?DeptName} = '...All' THEN TRUE
ELSE {SR_TEAM.DEPT_NAME} = {?DeptName}
)
AND
(
IF {?Type} = '...All' THEN TRUE
ELSE {RQST.RQST_TYPE_VLU} = {?Type}
)
AND
(
IF {?HandlingType} = '...All' THEN TRUE
ELSE {RQST.SPCL_HNDL_TYPE_VLU} = {?HandlingType}
)
AND
(
IF {?Region} = '...All' THEN TRUE
ELSE {RQST.LOC_VLU} = {?Region}
)





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top