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

Multiple Parameters Problem 1

Status
Not open for further replies.

ready4data

Programmer
Apr 9, 2001
18
US
I'm using Crystal 8.5 and connecting to SQL Server.
I'm using multiple parameters in the select expert and are having problems with one set of parameters. I've removed the working code (except for date range)to try to troubleshoot the problem area.
Here is the formula:
Code:
(if {?Result Code} <> "All" or {?Result Code} <> "All Dealer Visit Codes"
then{HISTORY.RESULT} = {?Result Code}
else if {?Result Code} = "All Dealer Visit Codes"
then {HISTORY.RESULT} in ["CIF IFAP Support Activity", "CPM PMO Support Activity", "DNB Dealer/Regional Nuts/Bolts", "DTA  Dealer Technical Assist", "DPR Dealer Plan & Review Session", "PRO New Dealer Prospective", "RMV RMAP Visit", "SEM Product Seminar", "SSA Sales Support Activity", "TIE Technical Information Exchange", "WBX Web-Ex"]
else if {?Result Code} = "All" or {?Result Code} = ""
then True) and
{HISTORY.RESULT} in ["APP Auth. Printer Provider", "ARI Activity Report Input", "CIF IFAP Support Activity", "CPM PMO Support Activity", "DNB Dealer/Regional Nuts/Bolts", "DPL  Product Launch Support", "DPR Dealer Plan & Review Session", "DTA Dealer Technical Assist", "OTH Other Dealer Visit Activity", "PRO New Dealer Prospective", "RMV RMAP Visit", "SEM Product Seminar", "SSA Sales Support Activity", "TIE Technical Information Exchange", "TRW Technician Ride With", "TSS Trade Show Support", "WBX Web-Ex"] and
{HISTORY.ORIGINALDATE} = {?Date Range}
The result code parameter is set up for multiple values. If I select All or leave it blank it returns no records. If I select 1 or more result codes it functions correctly.
There are certain codes that just pertain to dealer visits so I tried to preset those on the 4th line if "All Dealer Visit Codes" is selected but that doesn't work either.
Do I have the If statements in the wrong order or am I completely off in my formula.
Its my birthday so if someone could piont me in the right direction that would be a great present.

Scott
 
I'd suggest splitting it into several separate formula fields, and then see which work. Try this without any selection and see which formula isn't doing what you expected.

Nulls are always a thing to watch out for. Without isnull, Crystal will stop processing the formula when it hits a null value; the default assumption being that null means show nothing. I made this mistake several times while I was learning Crystal, because it's not obvious to someone who's used to other programming languages.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Try:

(
if {?Result Code} <> "All"
then
(
if {?Result Code} = "All Dealer Visit Codes"
then {HISTORY.RESULT} in ["CIF IFAP Support Activity", "CPM PMO Support Activity", "DNB Dealer/Regional Nuts/Bolts", "DTA Dealer Technical Assist", "DPR Dealer Plan & Review Session", "PRO New Dealer Prospective", "RMV RMAP Visit", "SEM Product Seminar", "SSA Sales Support Activity", "TIE Technical Information Exchange", "WBX Web-Ex"] else
if {?Result Code} <> "All Dealer Visit Codes" then
{HISTORY.RESULT} = {?Result Code}
) else
if {?Result Code} = "All"
then true
)
and
{HISTORY.ORIGINALDATE} = {?Date Range}

"All" should be listed as your topmost parameter option so that if there is no selection, the parameter will default to "All". Not sure why you had extra values for {history.result} in the second part of your original formula so maybe I'm missing something.

Anyway, happy birthday!

-LB
 
Thanks for the present LB.
It makes sense now seeing how it should be written.
I'll add the other code back and try all the parameters.
Thanks again,
Scott
 
LB,
One More item if you could.
I'm trying to get the info printed in the report header.
I previously used that works OK:(I'm using Left because I just want to display the first 3 chars of the result codes unless "All Dealer Visit Codes" is selected then I would display the whole string.
Code:
NumberVar Counter;
stringVar DisplayResultCodesSelected := "Result Code(s) Selected: ";
For Counter := 1 to UBound({?Result Code}) Step 1 Do
(DisplayResultCodesSelected := DisplayResultCodesSelected + left({?Result Code} [Counter],3) + ", ");
Left(DisplayResultCodesSelected, Length (DisplayResultCodesSelected)-2)

Now I'm trying to modify using some of your syntax but I can't get past the errors when trying to save.
Code:
NumberVar Counter;
stringVar DisplayResultCodesSelected := "Result Code(s) Selected: ";
(
if {?Result Code} <> "All Dealer Visit Codes"
then
For Counter := 1 to UBound({?Result Code}) Step 1 Do
(DisplayResultCodesSelected := DisplayResultCodesSelected + left({?Result Code} [Counter],3) + ", ");
Left(DisplayResultCodesSelected, Length (DisplayResultCodesSelected)-2)
) else
if {?Result Code} = "All Dealer Visit Codes" 
then
DisplayResultCodesSelected :="All Dealer Visit Codes"
I'm getting an error stating that the remaining text does not appear to be part of the formula. The cursor is blinking before the else.

Thanks,
Scott
 
Try the following:

NumberVar Counter;
stringVar DisplayResultCodesSelected := "Result Code(s) Selected: ";

if {?Result Code} <> "All Dealer Visit Codes" then
(
For Counter := 1 to UBound({?Result Code}) Step 1 Do
(DisplayResultCodesSelected := DisplayResultCodesSelected + left({?Result Code} [Counter],3) + ", ");
Left(DisplayResultCodesSelected, Length (DisplayResultCodesSelected)-2)
) else

if {?Result Code} = "All Dealer Visit Codes"
then
DisplayResultCodesSelected :=DisplayResultCodesSelected + "All Dealer Visit Codes"

-LB
 
LB,
Thanks again. Its starting to make sense to me now.

Have a Happy Turkey Day
Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top