Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Optional Parameter Post Reply Post New Topic
Author Message
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Topic: Optional Parameter
     Posted: 14 Sep 2009 at 11:13am
I want to have two parameters, but only one of them will be filled out.  How do I make it where only 1 of the 2 has to be filled in to run?
IP IP Logged
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Posted: 14 Sep 2009 at 11:14am
CR XI R2
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Sep 2009 at 3:03pm
This partially depends on the field types and characteristics of the params but in general you would want to add default values as "blanks" and then use a select statement to key off of that for your select statement.
 
if paramA=default_value then paramB=FieldB else
paramA=fieldA
 
If you are concerned they may select items from both and that is not allowed you would want to create a param 1 as a pick list to define the second param.
This really depends on the specifics but hope this points you in a useful direction.


Edited by DBlank - 14 Sep 2009 at 3:04pm
IP IP Logged
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Posted: 15 Sep 2009 at 11:58am

What if the parameter is going to accept multiple parameters?

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Sep 2009 at 12:11pm
I assume you mean multiple values in one parameter whcih would kill the if then option as it is an array.
Can you give a bit more of a real life example including what you want forced as limitations? Perhaps there is an easier approach.
IP IP Logged
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Posted: 15 Sep 2009 at 12:19pm
Yes I mean multiple values in one parameter, sorry

I have 4 parameters, Matter ID, Manager, Attorney, and Legal Specialist.  I want to run to option that none would be filled in, maybe one gets filled in and the rest blank, or maybe all are filled in.  They all need to be set to allow multiple values. 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Sep 2009 at 12:23pm
If a value is not filled in for any param youbasically want no select stament to run and grab all values in your source data, correct?
IP IP Logged
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Posted: 15 Sep 2009 at 12:25pm
yes
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Sep 2009 at 12:48pm
IMO
best approach here is to add an "...All" option for each param.
That better describes your process and makes the select statement very easy.
A few things I don't know. Are you using dynamic params that are populated by your data (not cascading) or are users just typing in options.
I recommend the dynamic.
Assuming that is the case you will need to add an ALL to each of those.
back to that in a sec. Once that is done the select statement is very straight forward and will allow for multiple values without an array issue.
 
({Param1} = "...All" or {Param1} = {table.Matter ID})
AND
({Param2} = "...All" or {Param2} = {table.Manager})
AND
({Param3} = "...All" or {Param3} = {table.Attorney})
AND
({Param4} = "...All" or {Param4} = {table.Legal Specialist})
 
Getting the "All" into the report...
You can add the "All" option in the DB itself per table that you want to use this process. You can do it in a view or stored proc as your source or you can do it in a command in crystal using a Union statement.
All depends on your larger set up and needs.
I added these dummy "...All" records into many tables in my DB as I need this option all the time and it did not cause me other problems.
Does this all make sense?


Edited by DBlank - 15 Sep 2009 at 12:52pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Sep 2009 at 12:49pm
FYI- I used "...All" instead of "All" because the "..." lead in makes it always first in a the alpha sorting
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum