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

Passing multiple values from subreport to main report to be used in another subreport?!

Status
Not open for further replies.

nicmcd77

Technical User
Oct 11, 2016
17
US
Hi all, I am using CR2008 and am lost. The first issue, is that I have a subreport that may have 1 or many values (Lot Number). I created this variable in the subreport and have it in the report footer

Lot Number subreport
WhilePrintingRecords;
shared stringvar VNteardown;
VNteardown:= {F4111.ILLOTN}

And this in the main report:
shared stringvar VNteardown;
VNteardown

I should be getting 3 values back in the main report but am only seeing 1 value. How do I change the formulas for my variables as sometimes it could be 1 lot number or multiple?

The second question is. I then need those Lot Numbers that have been passed to the main report to then be passed to a different subreport. (I assume I can't pass directly from sub to sub?). Is that even possible? I can pass the 1 value I'm getting back right now to a different subreport but wasn't sure if I could pass multiple? Please help!!
 
i think you can adapt Hilfy's answer in this post to meet your needs.


to copy/paste with my thought........
Code:
Create a formula that will store the dates to an array - something like this:

WhilePrintingRecords;
Shared DateVar Array shipDates;
If PreviousIsNull({Product#}) or {Product#} <> previous({Product#}) then
redim shipDates[1]; //Initialize the array to a single element
else redim preserve shipDates[UBound(shipDates) + 1];
shipDates[UBound(shipDates)] := {ship date value};

put the above in your lot number sub report and make sure it is in a report header or other location in your report prior to the second subreport.

Create a formula in your main report to hold the shared data.

WhilePrintingRecords;
Shared DateVar Array shipDates;


Code:
Create a formula for each date column you need for the report. The first one will be this:

WhilePrintingRecords;
DateVar Array shipDates;
shipDates[1]

The others will look like this (increase the number by one to get the value, if it exists, for each column):

WhilePrintingRecords;
DateVar Array shipDates;
if UBound(shipDates) >= 2 then shipDates[2]

put the above in your second subreport.
 
I have this in my subreport to gather the lot numbers (which I have been able to get, however when I run the subreport by itself, I'm getting 3 rows of values, shouldn't I get an array with commas all in one row? Also, don't I need a formula to share the variable with the main report or is this supposed to be doing that? My subreport only has 1 formula in it:

WhilePrintingRecords;
Shared StringVar Array LotNo;
If PreviousIsNull({F4111.ILLOTN}) or {F4111.ILLOTN} <> previous({F4111.ILLOTN}) then
redim LotNo[1] //Initialize the array to a single element
else redim preserve LotNo[UBound(LotNo) + 1];
LotNo[UBound(LotNo)] := {F4111.ILLOTN};


I have this formula in my main report and it won't let me save it saying "The result of a formula cannot be an array"
whileprintingrecords;
shared stringvar array LotNo;

I don't even know if I need the values to return to the main report as I want to take those 3 values and pass them ALL to a different subreport.
 
I think you could use a stringvar without the array...something like this...manually create a delimited list:

Whileprintingrecords;
Shared Stringvar AllLotNo;
If (PreviousIsNull({F4111.ILLOTN}) or {F4111.ILLOTN} <> previous({F4111.ILLOTN})) then
AllLotNo := ''
else AlLLotNo := AllLotNo & ", " & {F4111.ILLOTN};

 
I get 3 rows of blank values back.
If I only use this portion of the formula:
Whileprintingrecords;
Shared Stringvar AllLotNo;
AlLLotNo := AllLotNo & ", " & {F4111.ILLOTN};

If I just run the subreport alone, I get:
1. , VNPRL1011
2. , VNPRL1011, VNPRL1012
3. , VNPRL1011, VNPRL1012, VNPRL1013

If I use the formula above that you gave, the main report just runs and I have to close it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top