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!

Block IF statements... (CR6)

Status
Not open for further replies.

bujin

MIS
Oct 2, 2000
144
GB
Is it possible to do block IF statements in Crystal Reports 6? For example, in Pascal, I would write:

if <condition> then
begin
<statement>;
<statement>;
end
else
begin
<statement>;
<statement>;
end;

As far as I have been able to figure out, this is not possible in CR6. Please, someone prove me wrong as it would greatly simplify a problem I am having!
 
Hi Bujin,
Below is a copy of a more complicated if statement I have in one of my reports.

if {RISK_MANAGEMENT_PROFILE.RISK_STATUS} = &quot;A&quot; or
{RISK_MANAGEMENT_PROFILE.RISK_STATUS} = &quot;&quot; then
'ACT'
else
if {RISK_MANAGEMENT_PROFILE.RISK_STATUS} = 'S' or
{RISK_MANAGEMENT_PROFILE.RISK_STATUS} = 'O' then
'SUR'
else
if {RISK_MANAGEMENT_PROFILE.RISK_STATUS} = 'V' or
{RISK_MANAGEMENT_PROFILE.RISK_STATUS} = 'R' then
'RET'
else
'CBR'

Hope this helps.

LindaC
lcastner@co.orange.ny.us

 
I will take a wild guess that your two &quot;statements&quot; are variable assignments, which are really the only actions that you can do in CR. I have an example of this in my list of common formulas. See the FAQ on &quot;Common Formulas&quot; and look at the example for &quot;multiple variable assignments&quot;. Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
Thank you both for your quick replies. The FAQ has helped me, although I'm still confused about using further IF statements inside the block. Basically, the format of the formula I want is as follows:

IF <condition_1>
THEN
(
IF <condition_1a> THEN return <value_1a>
ELSE IF <condition_1b> THEN return <value_1b>
ELSE IF <condition_1c> THEN return <value_1c>
ELSE return <default_value>
)
ELSE IF <condition_2>
THEN
(
IF <condition_2a> THEN return <value_2a>
ELSE IF <condition_2b> THEN return <value_2b>
ELSE IF <condition_2c> THEN return <value_2c>
ELSE return <default_value>
)
ELSE
return <default_value>

Will this sort of nesting work, and if not, how can I structure it to get it to work?

Thanks again
Gareth.
 
Bujin: The nested IF blocks will work just fine - remember the ELSE portion is optional so you can omit this if you want the default to be the default for the field type e.g. 0 or '' David C. Monks
david.monks@chase-international.com
Accredited Seagate Enterprise Partner
 
I've got it working (I think!) with a slight modification - I just dropped the second condition and got rid of the final ELSE clause. I believe that produces the same results anyway.

Thanks again for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top