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

Parameters question - multiple values

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
US
Hi Folks, hope this isn't too dumb a question.

I have an existing report that the users want me to add functionality to. Currently it returns hundreds of pages of data, they want to be able to enter one or more of the code the program sorts by as a parameter to cut the volume down when the only need to look at a small part of the report.

The user interface will be a VB program, where I'll supply them a multi-select listbox to select codes from. I'm assuming I need to collect all the selections and concatenate them to send them through to the Crystal report, but I'm not sure what the format should be. I'd also like to know how to set up the parameter on the crystal side, if possible.

I have been using parameters for a while but have never tried sending more than one, or a varying number of them. Was wondering if anyone could provide some advice on how to handle it. The values will be strings, or text.

I'm using CR 8.5.

Thanks in advance. Any help you can offer will be greatly appreiciated.

Craig in NJ
 
Create a parameter in crystal just like always, but check off the "allow multiple values" box.

If you want to create a drop down list of valies ht the "default values" button.

You will need to write a formula to display all of the values as follows:

Join({?MVParameter},", ") Software Sales, Training and Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Which integration method are you using in VB?
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
A slight add-on to this question; is there a similar function/operator to Join in Crystal Version 7? Thanks!

Chris
 
No, Join() started in CR v8. Software Sales, Training and Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Craig,

To pass from VB multiple values into a Crystal multi-value parameter, you would use the following method call multiple times (once per each value):
------------------------------------------------------
Report.ParameterFields(1).AddCurrentValue(your value)
------------------------------------------------------

In my experience, you would find there are a few other challenges beyond the simple call above. You would need to ensure the target parameter is indeed multi-valued, ensure it is a Discrete (rather than range), ensure you are passing a compatible data type, discard any existing values in that parameter, etc. You can easily locate Properties and Functions to achieve all of the above in the Crystal Developer Online Help.

hth,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
To do the equivalent of a Join in CR 7 you'd have to write a formula akin to:

numbervar counter;
stringvar holder;
counter := count({?Multi});
//The above formula line retrieves the number of elements in the array.
while counter > 0 do
(holder := holder + {?Multi}[counter] + ',';
counter := counter - 1);
holder [1 to (length(holder)-1)]
//The above formula line removes the trailing ',' from the string.

This has a 254 character limitation.

-k kai@informeddatadecisions.com
 
I think v7 has problems with while loops, so I'm not sure that formula would go down.

You'd probably have to use an array to check the number of values in the parameter instead.
Code:
WhilePrintingRecords; 
NumberVar ValueCount;
StringVar Array ParameterArray := {?MyParameter};

ValueCount := Count({?MyParameter});

ParameterArray[1] + 

(If ValueCount > 1 Then ', ' + ParameterArray[2] + 
 If ValueCount > 2 Then ', ' + ParameterArray[3] + 
 ... etc)
Naith
 
Ken, sorry for taking so long to get back to you.

I'm using the older Crystal 7 OCX in this program. I'm passing the report name and parameters as properties to the control and then calling it's Execute method from VB6.

Thanks

Craig in NJ
 
You have v8.5 but your using the v7 OCX?
Not sure if the V7 OCX allows multiple value parameters - you might have to look that up in the documentation.
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top