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

Selection Formula Based On A String Array? 1

Status
Not open for further replies.

PMRiley

Technical User
Jun 29, 2004
47
GB
Is it possible to have a selection formula based on a string array?

I need to create a report which has a formula that specifies an array of product codes which the selection formula bases the records in the report on.

I have tried putting a loop into the selection formula that should check each item in the array, but the report is listing all records regardless of a matching product code.

This is what is in the selection formula at the moment...

NumberVar i;
Global StringVar Array JO;
for i := 1 to ubound(JO) do
(
If {PRODUCTS.Product} in JO
then {PRODUCTS.Product} = JO
)

(The above works fine in a normal formula)

If this is not possible, then can anyone suggest an alternative way of doing this? The report needs to be written this way as it needs to work for many different customers who all have different product codes for the same items. I want to avoid parameters etc. as once the formula is set for each customer, it never needs changing and I want it to remain as 'hidden' as possible.

(CR XI on SQL 2005 DB)
 
Record Selection could be changed as follows:
Code:
{PRODUCTS.Product} in ['YourProd1','YourProd2','YourProd3','YourProd4']
This way the values get passed in the WHERE clause of the SQL query

Bob Suruncle
 
Thanks for that suggestion, but I should have stated that I need to access that stringvar elsewhere in the report for other reasons and if at all possible, I would like to keep it so that the product code only need defining the once.
 
Your formula to define the array could be set up as follows:
Code:
@ProdArray
WhileReadingRecords ;
StringVar array prod := ['YourProd1','YourProd2']
""
Place this formula in the Report Header.

In your Record Selection Formula, change the formula as follows:
Code:
{PRODUCTS.Product} in StringVar array prod


Bob Suruncle
 
Fantastic!!!

I hate it when someone points out the obvious - I should have spotted that one ages ago! (If there's an easy way and a hard way, guess which way I always end up going!!!)

Thanks a lot - That worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top