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

Passing a Variable Value from Subreport to Main Report Problem 2

Status
Not open for further replies.

marckssg

Programmer
Nov 28, 2000
180
GB
Hi,

I'm passing a variable from a linked Subreport to a Main report via shared variable.

I'm getting a problem where by I only get the 1st value from my subreport appearing on my Main report.

Is this due to the positioning of the variable within my groups on the subreport/main report or down to an incorrect link between the subreport and main report.

Cheers

Marc
 
See my previous posts.

Every record in the Main report WILL show the same value, because the SubReport is running with the same values each time.

When you place the subreport in the Group Header, for every change of data within the header, the subreport will be re-evaluated. Because you are linking to the subreport via parameter fields from the main report, the re-evaluation will bring back the same data every time. Parameter fields are set in the main report once.

You need to link to the subreport via a field which will change when the Group Header changes, thus reevaluating the subreport and reevaluating the Variable.

Let me know if this is understandable, then we'll move on to which field you need to link to and where you need to place the Variable to return the info you're after....


Reebo
Scotland (Sunny with a Smile)
 
You probably heard the penny dropping even though your in Scotland! I just hope its the right penny!

I've linked {@Product Manufacture Grouping} = {?Pm-@Product Manufacture Grouping}

This being the Hugo Boss, Pierre Cardin etc etc that appears down the left hand column of the report.


Cheers

Marc
 
I think - but I am guessing - that this is very similar to a problem I had yesterday/today that I solved with the help from those on here by resetting the variable for each record....using separate details sections (or resetting the variable higher in the main report than the variable field)...see the thread from my post whhich is titled:

Evaluate shared variables for every record.....

My problem was that I had the same value repeating in the detail when there was should have been no data (it was simply using the last stored variable).....resetting the variables and undeylaying sections worked a treat.

But then this might not be what you are after at all :)
 
Thanks for that Rob, but I've tried it to no avail!

Cheers

Marc
 
Marc,

How are we doing mate?

Reebo
Scotland (Sunny with a Smile)
 
Not sure Reebo!

I've linked on the product group, with the subreport appearing in a section above where I want it displaying within the same group heading as the product manufacture grouping.

I'm still only seeing the bottom value from the subreport against each value with in the Product Manufacture Grouping.

Playing with the links as we speak, progress is slow its going to be a long night as if this doesn't work for tomorrow I'm for the high jump!!!

Cheers

Marc
 
Sorry to hear that......I'm off for the day now, so good luck, I'll just add a few more bits you can check if you get stuck:

Try moving the Subreport
Try moving the Variable in the Main Report
Try moving the Variable in the Sub Report
Check to Record Selection in the sub report, there should be a reference to the fields you are linking by

Good luck, and keep me posted.

Reebo
Scotland (Sunny with a Smile)
 
Thats exactly what I am doing!

Thanks for the help today, have a nice evening.

Cheers

Marc
 
Quick update...............still not working hence the early start!!!

I think I've tried just about every permitation of link and placement of both subreport and variable there is but to no avail!

Cheers

Marc
 
OK,
Looking more and more at your report, your subreport contains the same tables and formulas and parmeters as you main report......do you really need a subreport, or could it be you just need to do clever groupings in you main report to show the information correctly.

I think, seeing as deadlines are starting to get tight, you should post a sample of data, and how you wish it to be displayed in the report, We will get this sorted mate!


Reebo
Scotland (Sunny with a Smile)
 
Morning! Never doubted we would for a second!

The reason I used a subreport is that I want to compare figures from a store level to the all up figures across the group.

So my main report is grouped.
STORE
Product Group (ie Suit, Casual, Footwear.
Manufacture (ie Hugo Boss, Tom English)

To generate the all up figure I created a subreport that is the same grouping as above, but WITHOUT the Store grouping.

Independently both reports give me the correct figure.

I can't see a way in one report to bi-pass the Store grouping to work out the all up figure and then display it in the correct place on the report.

My ideal report will look like this

STORE 10001 Store Group
Suits
Hugo Boss 20% 15%
Tom English 40% 45%
Pierre Cardin 40% 40%
Caual
Casual Jackets 55% 60%
Caual Trousers 45% 40%

So the group figure ideally will come from the subreport and the store figure is already in place in the main report.


Cheers

Marc
 
OK, I think we're nearly there....

1, Join the Sub report to the main report by the group fields, Product Group and manufacture.

2, goto section expert, and create a couple of section for the group manufacture.

3, Please the subreport in section a of this group.

4, goto the subreport, this is pretty damn important, we are going to make sure the value of the variable is being set correctly......We need to set the value of the Variable to equal the information you are going to pass back, i.e. under group for Hugo Boss this value is 15%.....So you need to place the formula variable in the group footer where this 15% is, and within the formula use somwthing like :

Shared NumberVar grouppercent := {Value};

In preview of the subreport you should see this happening for all manufacture bits.

When passing a value accross from a subreport, you can only pass a single value at a time. What we have done above is basically saying, get me the single value from the subreport equal to Suits, Hugo Boss.

Does this make sense?



Reebo
Scotland (Sunny with a Smile)
 
It makes perfect sense, and I think I've done it to the letter but its not working! It always brings back 100%

Would it be easier if I e-mailed it over again, so you've got a better idea of where its all up to?!?!?!? Oh and point out any obvious mistakes!

Cheers

Marc
 
Yeah, that's fine, but I could do with you saving data with the report if it's ok to, if not don't worry.
Also check to see how big the report is after you've saved data, if it's a bit large, zip it.

Reebo
Scotland (Sunny with a Smile)
 
Hi,

I've mailed that over, playing with the links in the mean time, waiting for the data to come back at the moment, but I'm feeling strangly confident that this time its going to be fine!

Cheers

Marc
 
Marc,

Got it!

Take out the link between main report and sub report for Product Grouping and just leave manufacture grouping.

Reebo
Scotland (Sunny with a Smile)
 
Of did I mean the other way around?

Reebo
Scotland (Sunny with a Smile)
 
Marc,

I've got to leave at 13:00 uk time to catch a plane for the weekend.

Post how it went and I'll pick it up on Monday. Have a good weekend mate!

Reebo
Scotland (Sunny with a Smile)
 
Thanks for all the help, I think its working now, I'm just testing it against all 90 odd stores so its taking a while to work through the records!

I'm off on holiday this evening and won't be back for a week, if it doens't work my defence will be........
"well what've you done it worked when I left on Friday!"

Thanks again, its much appreciated.

Cheers

Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top