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

Need help with formula/parameter 1

Status
Not open for further replies.

ncchish

Programmer
Jul 29, 2002
86
US
I'm using Crystal 11 and I’m having trouble with a formula/parameter. I have a parameter called Mkt_Code. The user can choose “LIFECOMP”, “LCOMP-OTHER", “LIFECOMP-ALL”,etc. LIFECOMP-ALL is made up of all the codes LC,LCOT,LCAS,LCCP or they can choose just one to run. The problem I’m having with this is that I can run it and just get LIFECOMP data to return or one of the other single params if I comment out the part of the formula where it checks for the LIFECOMP-ALL. If I want to see records just for the LIFECOMP-ALL then I have to comment out the individual checks for LIFECOMP. It works one way or the other but I can’t get it to work with both codes in there. I've tried adding () but it doesn't seem to make a difference. I hope this makes sense and any help would be appreciated.

Formula:
//{@Mkt_code}

Stringvar mkt;

if {CDE} = "LC" then Mkt := "LIFECOMP"
else
if {CDE} = "LCOT" then Mkt := "LCOMP-OTHER"
else
if {CDE} = "LCAS" then Mkt := "LCOMP-STATE"
else
if {CDE} = "LCCP" then Mkt := "LCOMP-CPA"
else
IF {CDE} in ["LC","LCOT","LCAS",LCCP"] THEN Mkt := "LIFECOMP-ALL";
Mkt

Parameter:
//{?Mkt_Code}

LIFECOMP
LCOMP-OTHER
LCOMPSTATE
LCOMP-CPA
LIFECOMP-ALL

R/S:
{@Mkt_code} = {?Mkt_Code}
 
I would change your formula to:

if {CDE} = "LC" then "LIFECOMP"
else
if {CDE} = "LCOT" then "LCOMP-OTHER"
else
if {CDE} = "LCAS" then "LCOMP-STATE"
else
if {CDE} = "LCCP" then "LCOMP-CPA"

Then use a selection formula like this (which assumes there are other CDE values besides those listed):

(
(
{?Mkt_Code} = "LIFECOMP-ALL" and
{CDE} in ["LC","LCOT","LCAS","LCCP"]
) or
{@Mkt_Code} = {?Mkt_Code}
)

-LB
 
Thanks, LB.

It works when I just select to run one of the options but when I try to run for LIFECOMP-ALL I get the dreaded -905 Resource limit being exceeded.

 
I don't know what that is. I see no reason why it would create an error message. I was assuming that {CDE} was a database field.

-LB
 
Yes, it is the database field. I thought it would work too but so far the only way I can get it to work is to put everything in the R/S which is tedious and long. Thanks for your help.
 
I think you are making this too hard.

Please try the following:

//{?Mktparam} - String type - Description only shown

Value: 'ALL'
Desc: 'All Records'
Value: 'LC'
Desc: 'Lifecomp'
Value: 'LCOT'
Desc: 'LComp - Other'
Value: 'LCAS'
Desc: 'LComp - State'
Value: 'LCCP'
Desc: 'LComp - CPA'

In your seclection criteria:

//Selection matches to param value not shown at runtime
if {?Mktparam} like 'ALL' then
{CDE} in ["LC","LCOT","LCAS","LCCP"] else
{CDE} = {?Mktparam}

Let us know how you get on. If you need an additional formula with the values for any given reason then you can do this without affecting the selection method as an independant formula.

'J

CR8.5 / CRXI - Discovering the impossible
 
Thanks CR85User. This seems to work. Thanks to you both!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top