• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

Parameter inside of an array?

Is that any way I can make it work so that I could have an array that reads off a parameter?

Something like this:
{CONSIGNMENT_CODES.CONSIGNMENT_CODE} in [{?PARAMETER}]

My parameter pulls form a string field where I would enter values in this form:
"value", "value"

I get the erorr message saying that " the array needs to be subscripted"


I have tried setting to a variable but it does not work ...Any ideas?
0
patsylipp
Asked:
patsylipp
  • 4
  • 4
  • 2
  • +1
1 Solution
 
peter57rCommented:
I think I need a bit of clarification here.

Are you saying that your parameter values are based on a single database field and that for each database record this field can contain multiple values separated by a comma?
0
 
mlmccCommented:
Don't use the [ ]

{CONSIGNMENT_CODES.CONSIGNMENT_CODE} in {?PARAMETER}

By putting it in [ ], Crystal thinks you are creating a set and thus it wants single values.  Since it is treated as an array you can just use it.  Crystal will also evaluate it correctly as

{CONSIGNMENT_CODES.CONSIGNMENT_CODE} = {?PARAMETER}

mlmcc



0
 
patsylippAuthor Commented:
Thanks for your response Savant.

About your first response, yes, that is exactly what is going on.

About {CONSIGNMENT_CODES.CONSIGNMENT_CODE} in {?PARAMETER}

That was the first thing I have tried and it's not working unfortunately.

It reads my field as one big value, it does not distinguish the " "," ", " " for the different strings.

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
mlmccCommented:
WHat do you mean?

What field is being treated that way?

Is ?Parameter set to accept multiple values?

mlmcc
0
 
patsylippAuthor Commented:
I am sorry, you need more background info from me.

I am working with a software which has a simple bridge to upload crystal reports into this software so that customers can upload reports to our software and run Crystal from there.

The bridge has this parameter fields"
STR1
STR2

for strings...

so whenever I need to have a parameter onthe report, I create a parameter in crystal named STR1...
Once I loaded it works just fine. According to our developers, STR1 is being pulled as one whole single string value.

We only have STR1 - STR10...which is not enough for the project I am creating at the moment, I will need to enter many different records as a parameters(consignment_codes).

My idea was to be able to enter in STR1 only = "CON1", "CON2", "CON3".....

and have
{CONSIGNMENT_CODES.CONSIGNMENT_CODE} in [{?STR1}]

hoping that crystal would read
{CONSIGNMENT_CODES.CONSIGNMENT_CODE} in [ "CON1", "CON2", "CON3"]

but it doesn't work...crystal recognizes it all as one value and it looks for
"CON1", "CON2", "CON3"]
instead of looking at
"CON1"
and
"CON2"
and
"CON3"
seperately


Do you see any other way I could try in crystal to go around this lack of functionality on the bridge and have many  parameters within STR1 input field in our software??


0
 
mlmccCommented:
If you set the parameter to allow multiple values you can enter them individually then Crystal will treat them as an array.

If you want to enter the way you have it you could use

InStr({?Parameter},{CONSIGNMENT_CODES.CONSIGNMENT_CODE}) > 0

mlmcc
0
 
patsylippAuthor Commented:
I already have it set for multiple values, but the user will be using the bridge and not crystal reports itself...so entering them individually is the main issue, it has to be done all in this one field the entire issue is that the bridge interface doesn't allow you to enter values in the same way the one in crystal does ..

Second option:

It doens't like the parameter {?STR1}, it wants a string. The error message goes away if I do
"{?STR1}", but that wouldn't work since it's looking at it as a value.

 
0
 
mlmccCommented:
I just tried it and it works for me.

Where are you adding it?

Are you sure the type is STring?

mlmcc
0
 
James0628Commented:
When you said "it wants a string", I assume that you were referring to the InStr function?  If so, the problem is because your parameter allows multiple values (unless you've already turned that option off for this parameter).  The arguments to InStr have to be simple strings, and a multi-value parameter is treated as an array.  You could try using {?STR1} [ 1 ], to get the first value from the parameter.

 However, if the report is only going to be passed a single value, you should just uncheck the "allow multiple values" option for the parameter.  It's not going to do you any good if the parameter is only going to get single values, and it's just complicating things.  Then you could use the parameter with InStr without the [ 1 ].

 However #2, mlmcc's InStr test may not work, depending on your values.  For example, if the user selected ABC as one of the values, that test would also match "A", "B", "C", "AB" and "BC", because they are all contained in the string "ABC".

 Assuming that the values will never contain "," (which should be true, since you're using "," to separate the values), you could avoid false positives by putting ","s around the field:

InStr ("," + {?STR1} + ",", "," + {CONSIGNMENT_CODES.CONSIGNMENT_CODE} + ",")
 
 That way, for example, if the parameter contains "ABC" and CONSIGNMENT_CODE is "A", you end up looking for ",A,", so it doesn't match the "A" in "ABC".  I also added a "," before and after the parameter value, so "ABC,123" becomes ",ABC,123,".  If the value being passed to the parameter already has a "," at the end, you don't need to add one there.


 Having said all of that, depending on your db, if you can use something like a stored procedure or CR Command as the datasource for the report, another option might be to write some code for the db side that would take the comma-separated list of values in the string parameter and create a list of values out of it, and then check that list.  That would take some more work to set up, but could be much more efficient.  It depends on how CR handles the InStr test.  If it's able to translate it into something that the db can understand and send it to the server, then you may not have any problem.  But if it can't, CR will have to get all of the records from the server and then use InStr to filter out the ones that you don't want.  If you've got a lot of records, that could really slow things down.

 James
0
 
patsylippAuthor Commented:
good call on number one! number two would not work but I ended up going with your last suggestion...the array does not work in crystal for what I was trying to do.

I thoght it would be messy to cresate this report with a command,,,but I tried and the array in sql did just exactly what I was hoping for..cnc.consignment_code =  {?STR1}....and then entered values like:
'value','value2', ...it worked


Thanks for all the help!
0
 
James0628Commented:
You're welcome.  Glad I could help.

 James
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now