| Author |
Message |
hikarimay10
Newbie
Joined: 03 Jun 2010
Location: Jamaica
Online Status: Offline
Posts: 10
|

Topic: Display subset of parameter values in header Posted: 03 Jun 2010 at 11:34am |
Dear All: I am using Crystal Reports XI. I have two parameters and used formulas to display them in the report header. Both are string, dynamic and allow multiple values and multiple discrete values. The formulas are shown below. However, when I checked the report details even though the user selected multiple parameter values only some records are returned which is correct. However, now I want to change the report header to show the values that were returned in the details and not the values that the user selected. This means the report header values would now be a subset of the full parameter values. For e.g., the user selected "mining, IT, transport, films" but only "mining,films" have records so I want only those to be in the header. The users are complaining that they see the header and then think something went wrong so instead it should only show values for those with records. What should the formulas be? Thanks. Sector Local StringVar str := ""; Local NumberVar strLen := DistinctCount({?Sector}); Local NumberVar i;
For i := 1 To strLen Step 1 Do
(
str := str + {?Sector}+", "
); str := Left(str, Length(str)-2); str
Status
Local StringVar str := ""; Local NumberVar strLen := DistinctCount({?Status}); Local NumberVar i;
For i := 1 To strLen Step 1 Do
(
str := str + {?Status}+", "
); str := Left(str, Length(str)-2);
str
|
IP Logged |
|
|
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
|

Posted: 07 Jun 2010 at 4:08am |
if you want what was returned, I would try a subreport that compiles a delimited string and returns the string to the main report via shared variables.
the formula would be something like:
shared stringvar sResult;
if instr(sResult, {table.field}) = 0 then
sResult := sResult + ", " + {table.field};
then in the main report:
shared stringvar MID(sResult, 2);
HTH
|
IP Logged |
|
hikarimay10
Newbie
Joined: 03 Jun 2010
Location: Jamaica
Online Status: Offline
Posts: 10
|

Posted: 10 Jun 2010 at 7:11am |
Hi: I did not knew that subreports could be created because I am not very experienced in using crystals  . I created one and am still experimenting with it first before adding your formula. I will continue testing and inform you of my results . Thanks for ur help lockwelle! :) hikarimay10
|
IP Logged |
|
hikarimay10
Newbie
Joined: 03 Jun 2010
Location: Jamaica
Online Status: Offline
Posts: 10
|

Posted: 10 Jun 2010 at 9:11am |
Hi again: I tried the following formula in the main report so it shows the lists of values that comes in the report and not
everything that the user selects which is correct. But it only shows the values if I put it at the report footer. I also tried them in the sub-report and same thing. I also used the shared variable to get the result from sub-report to main report but it did not work and crystal help only says shared is passed to sub-report not from it. Shared stringVar sectorVal; WhilePrintingRecords; sectorVal:= sectorVal+","+{Command.ProspectSector};
Local stringvar array sectorArray:=Split({@sectorsVal},","); Local StringVar str := ""; Local NumberVar strLen := DistinctCount(sectorArray); Local NumberVar i;
For i := 1 To strLen Step 1 Do ( str := str + sectorArray+", "; ); str := Left(str, Length(str)-2); str := Right(str, Length(str)-1); str;
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
|

Posted: 11 Jun 2010 at 3:07am |
in the second block of code, you are missing the reference to the shared variable.
Add Shared stringVar sectorVal;
above the line with split on it. Maybe it isn't needed, but I have always used it and not had an issue..
|
IP Logged |
|
hikarimay10
Newbie
Joined: 03 Jun 2010
Location: Jamaica
Online Status: Offline
Posts: 10
|

Posted: 11 Jun 2010 at 3:52am |
Ok, new code for last segment is shown below. But how do I get it to display in header not footer? When I move it to header it gives error or is blank. Even in the subreport it only shows in footer but user wants it in header. Plus subreport uses links for getting the parameter value so it only works if I put sub-report in footer. Shared stringVar sectorVal; Local stringvar array sectorArray:=Split(sectorVal,","); //Local stringvar array sectorArray:=Split({@sectorsVal},","); Local StringVar str := ""; Local NumberVar strLen := DistinctCount(sectorArray); Local NumberVar i;
For i := 1 To strLen Step 1 Do ( str := str + sectorArray+", "; ); str := Left(str, Length(str)-2); str := Right(str, Length(str)-1); str;
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
|

Posted: 11 Jun 2010 at 7:41am |
For a formula, or a running total, the data has to be read prior to printing. A header is printed before all the data for the group is read, typically. A method to get around this is to create a second part of the header (insert section below), move it above the current header and call the subreport from there. Yes there will be a performance hit, but that it is the only way to get a summary line, like this, to appear in the header.
HTH
|
IP Logged |
|
hikarimay10
Newbie
Joined: 03 Jun 2010
Location: Jamaica
Online Status: Offline
Posts: 10
|

Posted: 11 Jun 2010 at 12:51pm |
|
I will try that on Monday although since the sub-report uses the parameters of the main report through links I doubt that it will work. Can be the parameters be placed on the sub-report instead? How do I get data from sub-report formula field into main report formula field, I tried but it was blank?
|
IP Logged |
|
|
|