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

Is it Possible to Assign StringVar Array 1

Status
Not open for further replies.

WestView

Technical User
Jan 7, 2003
67
US
Don't know if this is possible, but....

I have a database field on my report called 'product_code' (string). This field is also a multiple-value report parameter. I need to create a formula field next to it calles, say, 'custom_code' that displays a different value (related to the 'product_code') that is assigned to it by the user.

For example, if the user chooses run the report using product_codes 500, 501 & 502 in the parameter prompt, the user could assign a value of 'ABC' to product_code 500, 'EFG' to 501 and 'HIJ' to 502. These values would populate the 'custom_code' field for all the matching records in the 'product_code' field.

I know how to use a parameter field to assign a variable to a formula field, but not for an array like the example above.

Any/all help with this would be GREATLY appreciated!

Thanks,

Tom
 
You can't pick up the descriptions from the parameter pick list but you will be able to get the descriptions if the product codes are in the database.

To get the third product code description use.
WhileReadingRecords;
Global Stringvar Array ProdDesc [ 400];
if {table.productcode} = {?parameterlist} [3] then
ProdDesc [3] := {table.productdescrption}

At least that is how I would do it. What you would then do with that I'm not sure.

Editor and Publisher of Crystal Clear
 
Hi chelseatech ,

Thank you for your response!

What I'm trying to do is this. I want the user to be able to assign a custom code to the 'product_code' database field they select in the parameter prompt. Thus, if the user chooses run the report using 'product_codes' 501 & 502 in the parameter, the user could assign a value of 'ABC' to 'product_code' 501 and 'DEF' to 'product_code' 502. These values would populate the 'custom_code' formula field for all matching records in the 'product_code' field. Example:

Record_id product_code custom_code
--------- ------------ -----------
1 501 ABC
2 502 DEF
3 501 ABC

I'm just not clear on how to implement your suggestion with this example. Could I trouble to explain a little further? I would greatly appreciate it!!!

Thanks agaon,

Tom
 
Set up two parameters: {?ProdCode} and {?CustCode}. Both should be multiple value parameters.

You would add the following as your record selection criterion:

{table.prodcode} = {?ProdCode}

Then create a formula:

numbervar i := ubound({?ProdCode});
numbervar counter;
stringvar x;

for counter := 1 to i do(
if {table.prodcode} = {?ProdCode}[counter] then
x := {?CustCode}[counter]);
x

This formula will give you the results you want by assigning the custom codes in the order they are entered by the user to the product codes in the order they are entered.

The only limitation is that the user would not have a display of entered product codes to look at while entering the corresponding custom codes (unless he/she was using a hard copy of a table to enter both codes).

-LB
 
LB,

Brilliant!!! That worked beautifully! Thanks SO much!!!!!!

- tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top