Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Report Titles and Multi-Value Parameters Post Reply Post New Topic
Page  of 2 Next >>
Author Message
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Topic: Report Titles and Multi-Value Parameters
    Posted: 08 Jan 2015 at 3:53am
I always struggle with this issue and have never quite figured out a solution that works well. I'm sure that people here who have been using CR longer than me have already mastered this issue.

I routinely create reports where the user can select one of many values from a parameter. I need a way for the report title to show me all of the values they selected.

For example, on my current report I have a parameter {?Book} which is tied to field {table.book} in my database.

The user can select 1 or a dozen or more values from this field. How do I show all the values they selected in the report title?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 08 Jan 2015 at 4:43am
look up the create a formula and look up the JOIN function.
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 08 Jan 2015 at 5:44am
Thanks kevlary. That looks like it will be extremely useful.

EDIT:

I still don't understand how the parameter will be used here. The JOIN function wants a string array. The parameter contains nearly 100 values for the user to choose from and they can choose any of them.

Edited by adavis - 08 Jan 2015 at 5:49am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Jan 2015 at 7:38am
make a formula field as
JOIN(?param,", ")
display in report header
 
or do you mean you are selecting from a list of ints or numeric values and it won't work due to that?


Edited by DBlank - 08 Jan 2015 at 7:39am
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 08 Jan 2015 at 7:44am
Yes, I am using numeric values in this instance.


However, I did try to use the join function with a string parameter as well and was given the same error.

Edited by adavis - 08 Jan 2015 at 7:46am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Jan 2015 at 8:05am
From Ken Hamady's site
 
 WhilePrintingRecords;
    Local NumberVar Array InputNum := {?AnyNumericPrompt};

    //The last field above is the one you replace with your prompt field
 
    Local StringVar str := "";
    Local NumberVar strLen := Count (InputNum);
    Local NumberVar i;
            For i := 1 to strLen
            Step + 1
            Do (str := str +', '+ ToText(InputNum ,0,''));
 
    str [3 to Length(str)] 
EDIT: link updated to correct link


Edited by DBlank - 09 Jan 2015 at 4:03am
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 08 Jan 2015 at 8:14am
Thanks DBlank.
I had actually read that earlier too, but wasn't able to get it to work right. For some reason it keeps wanting to insert all the possible values in the field and not just the ones the user defines in the parameter, which ends up producing an error stating that the text field has too many characters.

I'll come back to it later. My brain hurts.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Jan 2015 at 8:20am
copy it exacly and replace the part with your actual numeric parameter name. I think you want to use ?Book...
 
 WhilePrintingRecords;
    Local NumberVar Array InputNum := {?Book};

    //The last field above is the one you replace with your prompt field
 
    Local StringVar str := "";
    Local NumberVar strLen := Count (InputNum);
    Local NumberVar i;
            For i := 1 to strLen
            Step + 1
            Do (str := str +', '+ ToText(InputNum ,0,''));
str [3 to Length(str)] 
 


Edited by DBlank - 09 Jan 2015 at 4:06am
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 09 Jan 2015 at 3:40am
DBlank,

That is the exact formula I tried. When I check the formula for errors, I get an error on InputNum as "this array must be subscripted. For example: Array."

After getting that error, I assumed that I misunderstood the formula and that maybe I was supposed to replace the InputNum text with the number field from my table. I tried that too. The formula looked like this:

WhilePrintingRecords;
    Local NumberVar Array InputNum := {?Route};
    //The last field above is the one you replace with your prompt field

    Local StringVar str := "";
    Local NumberVar strLen := Count ({ub_group.book});
    Local NumberVar i;
            For i := 1 to strLen
            Step + 1
            Do (str := str +', '+ ToText(({ub_group.book}) ,0,''));

The formula, however, returned "True" instead of a list of the values selected from the parameter.

I'm not sure what to try next. I've been working on this for ages it seems. Typically I just get too busy with other things I need to get done, so I just give up and change the title to "selected valued" or something, but I would really like to solve this issue and become a better crystal report writer.

Thanks for your donated time, as always.


Edited by adavis - 09 Jan 2015 at 3:41am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jan 2015 at 4:07am
I posted the wrong link, it is now corrected to Ken Hamady's site
 
don't forget the last line
 
str [3 to Length(str)] 
 


Edited by DBlank - 09 Jan 2015 at 4:07am
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.