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

Displaying strings while passing corresponding numbers as Parameters

Status
Not open for further replies.

kallis4fun

Technical User
Jun 8, 2007
11
AU

CR11/SQL 2000.
Can any one help me to concatenate strings(text fields) when passing their corresponding numbers(multi) as Parameters. the user can select upto 20 numeric and we need to display their corrsponding text values in PH of report in a single line sepearted by ",".I have 4 different parameters where the user can multi select.

eg: I have states

stateid name
1 ALabama
2 California
3 New York
4 Pensylvania
5 Nevada
6 Massachussets
. .....
. .......
and so on

if the user passes 2,3,4,5,6 as values to the report,I need to display

Selected States: California,New York,Pensylvania,Nevada, Massachussets

in the Page header of report.

Thanks in advance!
Kallis


 
You could either do this by inserting a subreport that is linked to the main report on the parameter (linked to the ID field in the sub), and where you add the table containing the state names, and concatenate them in a formula placed in the detail section:

whileprintingrecords;
stringvar x := x + {table.state}+",";

Then in the subreport footer, place this formula:
whileprintingrecords;
stringvar x;
left(x, len(x)-1)

Finally, suppress all sections except the subreport footer. You might want to format the formula to 'can grow.'

The other method would be to hardcode each state in a formula:

whileprintingrecords;
numbervar i;
numbervar j := ubound({?stateno});
stringvar x;
for i := 1 to j do(
select {?stateno}
case 1 : x := x + "Alabama"+","
case 2 : x := x + "California" +","//etc.
);
left(x,len(x)-1)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top