INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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

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

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

(OP)
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!!

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

i think you can adapt Hilfy's answer in this post to meet your needs.
http://www.tek-tips.com/viewthread.cfm?qid=1770377


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.

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

(OP)
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.

RE: Passing multiple values from subreport to main report to be used in another 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};

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

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close