cancel
Showing results for 
Search instead for 
Did you mean: 

Parameter

Former Member
0 Kudos
Hi All,

I have to create a  parameter in crystal reports where I need to show if user wants to he can choose 1 or all for all id's and if he opts for option2 he has to enter id to display the results.

if ?id = all then id = all id's

else ?id = ?id

Thanks,
Chandu

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Chandu,

Do you mean you need a wildcard with the value ALL in the list of values?

If the report is based off of Tables, Here's what you need to do:

1) Create a command object with this code:

Select table.field from table

UNION

Select 'ALL' from table

Make sure you DO NOT join this command to other tables.

2) Create a new dynamic prompt and under value choose the field from this command object

3) Go to the Record Selection Formula and use this code:

{?Prompt} = "ALL" or

{?Prompt} = {Database_Field}

-Abhilash

Former Member
0 Kudos

Hi Abilash,

Thanks

But I have a created a command object crystal report.

I have a code like this

select table1.id, table.name

From

table1

left outer join table2 on table1.col1 = table2.col1

Now I need a parameter on table1.id

when ?parameter = 1 then result should be based of  all Id's

or parameter = some id given by the user of the report then result should be based of that id only.

Thanks for the help.

abhilash_kumar
Active Contributor
0 Kudos

You'd first need to modify the existing command object:

1) Add a prompt in the command window

2) Add it to the where clause so that it looks like this:

Where

({Prompt} = 1 OR

Table1.ID = {Prompt})

3) Create a second command object based on the guidelines from my previous reply. Just replace 'ALL' with 1 as I gues you want the number 1 to be the wildcard

4) Do NOT join this command to the other command object

5) Go to the Field Explorer > Edit the prompt > Set it to Dynamic and under Values choose the field from the second command object that you create in step 3.

-Abhilash

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks Abhilash. It worked