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!

Multiple Value Formula Field 1

Status
Not open for further replies.

Icebun

MIS
Jul 31, 2002
19
GB
Hi,

I'm try to display all the values from a multiple value parameter field in the report header.

There is an article on this on Crystal's website that mentions using the following code :

numbervar counter;
numbervar final;
stringvar holder;
counter := count({?Multi});
while counter > 0 do
(holder := holder + {?Multi}[counter] + ',';
counter := counter - 1);
holder [1 to (length(holder)-1)]

(I've changed 'Multi' to the field name on my report).

Each time I try this, I get an error message saying that 'The following text does not appear to be part of the formula'. This problem appears to be after line 4 (i.e. the while statement).

Does the 'while' statement actually exist in Crystal ? I can't see any reference to it in Help. and Crystal does seem to be having a problem with this line of code.I'm using version 7.0.1.100.

 
If your Multi contains string values try:

join({?Multi},", ")

Its much easier that working the loop, its available in 8.5, not sure about 7.

As far as the loop goes, it works fine for me if Multi is a string. If multi isn't a string, try totext({?Multi}[counter]) and see if that helps.

Lisa



 
The While statement should be fine in v7, however, it sounds like you may have missed a ";". That is where I usually get that error. Chris
DFW Crystal User Group
 
Join isn't available in v7.

Tried inserting a ; after the while statement to no avail.

The problem is definitely the while statement. If I remove it, the formula validates with no probs.

So, any other methods for getting multi value parameter fields to print ?
 
If count({?MVParm}) = 1 then {?MVParm}[1] else
If count({?MVParm}) = 2 then {?MVParm}[1]+", "+{?MVParm}[2] else
If count({?MVParm}) = 3 then {?MVParm}[1]+", "+{?MVParm}[2]+", "+{?MVParm}[3] else..............

Continue this logic for as long as it takes to conver the maximum number of paramters you could reasonable expect the user to enter.

If the parameter is numberic or date, you will need to use the totext() function in conjunction with this formula.

If the formula result exceeds 255 character you will get an error. This is a limitation of CR due to be resolved with CR V9.

Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top