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!

Parameter Fields 1

Status
Not open for further replies.
Nov 12, 2003
22
GB
I have set up a parameter field to allow users to select more than one value for the report, they could have up to 6.

I want to be able to display the values they have included in their report on the front page.

I have tried adding the parameter to display on the front page but it only picks up the first parameter selected, not any of the others.....any ideas?
 
The reason for this behaviour is that a parameter that can contain multiple values is treated as an array. So you'll have to make sure you display the array's elements to get the result you want.
Using CR8.5, I can offer you the following solution:

Supposing your parameter-field is named param, create a formula that looks like:

local numbervar l_i;
local stringvar l_s:='';
for l_i:=1 to ubound({?Param}) do
(
l_s:=l_s & {?Param}[l_i] & chr(13);
);
l_s;

Then place this formula in the header section of your report and make sure that the formula field's "can grow" property is set.

Keep in mind that you might get into trouble when the total of all parameter values characters exceeds 255 characters.


 
If your parameter is a string you could use:

join({?parameter},chr(13))

Or:

join({?parameter},", ")

Or, if it is a number parameter:

stringvar parm;
numbervar counter;
numbervar i := ubound({?numberparm});

for counter := 1 to i do(
parm := parm + totext({?numberparm}[counter],0,"") + ", ");
left(parm, len(parm)-2);

-LB
 
I have created the following formula to try and get multiple parameters selected to show:

if (join({?area},", ")) = "2" then "Bournemouth" else
if (join({?area},", ")) = "3" then "Poole" else
if (join({?area},", ")) = "51" then "Beaminster" else
if (join({?area},", ")) = "52" then "Bridport" else
if (join({?area},", ")) = "53" then "Dorchester" else
if (join({?area},", ")) = "54" then "Lyme Regis" else
if (join({?area},", ")) = "55" then "Sherborne" else
if (join({?area},", ")) = "56" then "Swanage" else
if (join({?area},", ")) = "57" then "Wareham" else
if (join({?area},", ")) = "572" then "Bere Regis" else
if (join({?area},", ")) = "578" then "Wool" else
if (join({?area},", ")) = "581" then "Weymouth" else
if (join({?area},", ")) = "585" then "Portland" else
if (join({?area},", ")) = "61" then "Blandford" else
if (join({?area},", ")) = "62" then "Christchurch" else
if (join({?area},", ")) = "63" then "Ferndown" else
if (join({?area},", ")) = "64" then "Gillingham" else
if (join({?area},", ")) = "65" then "Shaftesbury" else
if (join({?area},", ")) = "66" then "Verwood" else
if (join({?area},", ")) = "67" then "Wimborne" else
if (join({?area},", ")) = "677" then "Sturminster Newton"

This works fine if only one area is selected in the parameter but as soon as two or more values are selected in the parameter then nothing shows.

what am i doing wrong?

 
Sorry I am not able to help, but I am going to have to do this very soon, so these answers have been very helpful for me.
 
Please note that if you use the join option with chr(13), you must format the field to "Can Grow."

If you are trying to show the related description field instead of the parameter field itself, then use a formula like the following:

stringvar parmdesc := "";
numbervar counter := 0;
numbervar i := ubound({?parameter});

for counter := 1 to i do(
parmdesc := parmdesc + (if {?parameter}[counter] = "2" then "Bournemouth" else
if {?parameter}[counter] = "3" then "Poole" else
//add in other options here
"")+ ", ");
left(parmdesc, len(parmdesc)-2);

-LB
 
I have also done this to pass in some parameters as numbers, and then to write at the top of the report which parameters were selected.
My problem is that I now neeed to translate these numbers (which are location IDs) into the location name. If I was doing this normally it would be a very simple select:

stringvar param;
numbervar counter;
numbervar i := ubound({?MyParam});

for counter := 1 to i do(
param+=select name from location where id = {?MyParam}[counter];
)

Is there any way to do something like this?
 
Katy,

You could do it using a subreport in the header based on your Locations table, to which you pass the parameter to get the names. Using a formula in the subreport, you could have it output a comma separated list of the location names.

-dave
 
Thank you, I will either do it like you say, or I will get the application to pass in the names as well as the IDs.
 
Or, if there aren't too many, you could hard code the descriptions into the formula as in my last post.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top