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

SubReport Help

Status
Not open for further replies.

tc3596

Technical User
Mar 16, 2001
283
Here's my situation:
I have a main report with 2 parameters (start date and end date) My main report displays cusid, cusname and total sales by cusid. Main Report is grouped by cusid. Everything lies in group header for cusid and is restricted by the two parameters. After choosing dates for parameters, I get 5 cusid's (5 groups). I want my subreport to display all cusid's that did not display on the main report. I can't hard code the cusid's on my main report as they will change often. Any thoughts would be helpful. Thank you in advance.

Tim
 
yes you could place your subreport in the main report, report footer...since you would run this as stand alone with no links as you want all cusid's left over.

Create a shared array that will collect the cusid's

@initialization (suppressed in main report report header)

WhilePrintingRecords;
//make the array 50% larger than necessary
shared stringVar array IDs := ["","","","",......"","","","",""];
numberVar iCount := 0;


now in the custid group header place the following formula

@collectCustID (suppressed in custid header)

WhilePrintingRecords;
shared stringVar array IDs ;
numberVar iCount ;

icount := icount + 1;
IDs[iCount] := {Table.CustID};


now in the subreport you will generate the information on ALL CUSTID's, since yuo cannot use an array in the record select. but in the conditional suppress of the section displaying the information you will put the following formula

whilePrintingRecords;

shared stringVar array IDs ;

{table.CustID} in IDs;

this will suppress the records that have CustID's displayed in the main report

Jim Broadbent
 
@initialization was created and is suppressed in my report header, @CollectCusIds was created and placed in the group header (not suppressed so I can see the value). Crystal 7 (@CollectCusIds) did not like
IDs[iCount] := {Table.CustID}; so I had to make it
IDs[iCount] = {Table.CustID}; ("remaining text isn't a part of the formula") as well as the (Ids[icount]) part. It saved correctly but once ran, Crystal says "a subscript must be between 1 and size of array". So, I replaced it with
IDs[1] = {Table.CustID}; (2, 3, 4 or 5 won't work)
I implemented the subreport suppression.

When I refresh the data, the subreport suppresses like it's supposed to , but only the first value (ids[1]) in the main report. Any thoughts?

In case I've confused anyone,
main report shows 5 cusid's after criteria: (5, 23, 66, 76 and 77) Subreport shows all but cusid = 5....(which is ids[1])

Tim
 
OK, here's what I discovered. @initialization isn't working. If I hard code the cusids in with all instructions above followed, it works fine.

i.e.
@initialization

WhilePrintingRecords;
//make the array 50% larger than necessary
shared stringVar array IDs := [5, 15, 23, 66, 77];
numberVar iCount := 0;

My variable actually needs to be a number, so I tried [0,0,0,0,0,], but still nothing. I actually tried using a formula from Crystal in pdf file about arrays, but it didn't like the syntax. Any help out there?
 
Sorry....you did not say you were using CR7....arrays won't work as I have shown them in my above post unless you have CR 8.0 or better Jim Broadbent
 
So, do you have any suggestions to accomplish this task? I appreciate your efforts.
 
well Arrays in CR 7 are very limiting...to the point of being useless in my opinion...since you cannot assign their values from variables then.

If there are not too many CUSID's used in the main report we could assign them to single shared variables and do a similar test as we tried before....just more awkward...

Ok let's try this...similar format as before

@initialization (suppressed in main report report header)

WhilePrintingRecords;

shared stringVar ID1:= "";
shared stringVar ID2:= "";
shared stringVar ID3:= "";
shared stringVar ID4:= "";
shared stringVar ID5:= "";
shared stringVar ID6:= "";
shared stringVar ID7:= "";
shared stringVar ID8:= "";
shared stringVar ID9:= "";
shared stringVar ID10:= "";
//make the number of shared variables 50% larger than
//necessary I show the final value as IDn here
shared stringVar IDn:= "";
numberVar iCount := 0;

the collect custid doesn't change much

@collectCustID (suppressed in custid header)

WhilePrintingRecords;
shared stringVar ID1;
shared stringVar ID2;
shared stringVar ID3;
shared stringVar ID4;
shared stringVar ID5;
shared stringVar ID6;
shared stringVar ID7;
shared stringVar ID8;
shared stringVar ID9;
shared stringVar ID10;
//make the number of shared variables 50% larger than
//necessary I show the final value as IDn here
shared stringVar IDn;

numberVar iCount ;

icount := iCount + 1;

if iCount = 1 then
ID1 := {Table.CustID}
else if iCount = 2 then
ID2 := {Table.CustID}
else if iCount = 3 then
ID3 := {Table.CustID}
else if iCount = 4 then
ID4 := {Table.CustID}
else if iCount = 5 then
ID5 := {Table.CustID}
else if iCount = 6 then
ID6 := {Table.CustID}
else if iCount = 7 then
ID7 := {Table.CustID}
else if iCount = 8 then
ID8 := {Table.CustID}
else if iCount = 9 then
ID9 := {Table.CustID}
else if iCount = 10 then
ID10 := {Table.CustID}

//Keep going til you hit the "nth" value
else if iCount = n then
IDn := {Table.CustID};

now in the subreport you will generate the information on ALL CUSTID's, since you cannot use a shared variable in the record select. but in the conditional suppress of the section displaying the information you will put the following formula

whilePrintingRecords;

WhilePrintingRecords;
shared stringVar ID1;
shared stringVar ID2;
shared stringVar ID3;
shared stringVar ID4;
shared stringVar ID5;
shared stringVar ID6;
shared stringVar ID7;
shared stringVar ID8;
shared stringVar ID9;
shared stringVar ID10;
//make the number of shared variables 50% larger than
//necessary I show the final value as IDn here
shared stringVar IDn;

if ID1 = {Table.CustID} or
ID2 = {Table.CustID} or
ID3 = {Table.CustID} or
ID4 = {Table.CustID} or
ID5 = {Table.CustID} or
ID6 = {Table.CustID} or
ID7 = {Table.CustID} or
ID8 = {Table.CustID} or
ID9 = {Table.CustID} or
ID10 = {Table.CustID} or
//Keep going til you hit the "nth" value
IDn = {Table.CustID} then
true
else
false;

there you go...that should work....rather long and tedious though....arrays and for-next loops are much more convenient to use :)




Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top