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
 
Sorry forgot to mention I'm using Crystal Reports 9.

Cheers

Marc
 
Where have you placed the sub report within the main report?
Where have you placed the variable within the main report?



Reebo
Scotland (Sunny with a Smile)
 
I've tried (mainly in desperation!) placing the sub-report in each header and footer, along with in the details section.

The variable formula is in the main report in a group header where I'd want the information to be displayed.

Cheers

Marc
 
You must evaluate the Sub Report before using the variable within the main report.

Therefore, within section expert create a second Group section, place the sub report in Group Section a and the variable in group section b.

Try this and post the results.

Reebo
Scotland (Sunny with a Smile)
 
Tried that, and I just get the same value against each record in the main report.

Cheers

Marc
 
How are you linking your sub report to the main report?


Reebo
Scotland (Sunny with a Smile)
 
Within the main report there are 4 parameters.

I'm linking on two of these parameters.

I've tried linking via both the {? PM} parameter and the normal {?} parameter, both have the same effect.

Cheers

Marc
 
Ok, i'm slightly lost now.....I think it would be best if I take a look at your report. I don't need to see any data and the report will be smaller if you click of the Savce data with report option bfore saving.

If sending the report is a problem, then don't worry about it, else send it to reebo_99@hotmail.com and I'll help further.

Reebo
Scotland (Sunny with a Smile)
 
The reason you are returning the same value everytime is you haven't linked the subreport to the main report correctly.

You have selected to link by ?Suit Selection and ?Season Start Date, but haven't specified fields within the Subreport to link these to.

When selecting a field to link by, this becomes part of the Record Selection in the sub-report, without linking via a field the sub-report will run exactly the same each time, returning the same results.

OK, to recify, right click subreport and choose Change Subreport Links, Remove the fields cuurently chosen, then add in the fields again, this will give you some selection at the bottom, choose the fields within the sub-report to link.

Let me know how you get on and if it helps or not. I'll keep hold of your report for the time being incase this doesn't help, but it should!


Reebo
Scotland (Sunny with a Smile)
 
Whoops sorry about that! Its very much a work in progress thing, the links where correct and changing them was one of the many trial and error things I was playing with to fix the missing value problem.

Have restored them to the correct links and it still doesn't work.



Cheers

Marc
 
What are your sub-report links now?

Reebo
Scotland (Sunny with a Smile)
 


{KASSTRNS.KAS_DATUM} = {?Season Start Date}
and
{ARTIKEL.ART_WARENGR} = {?Suit Selection} and

"Datum" being the date field and "Warengr" being the Suit type.



Cheers

Marc
 
I take it {?Season Start Date} and {?Suit Selection} are parameters from the Main report.

If so then you will always bring the same data back as these parameter fields don't change from the Main Report. You need to link to the subreport via a database field or a calculated field whose value changes, thus changing the result of the subreport.

Reebo
Scotland (Sunny with a Smile)
 
If I link on parameter then when the user changes the date for example (which is flexible) then this brings back different data in the Subreport? Does it not?

I'm happy with the information generated by the subreport, this is correct. If I place the subreport in the header of my main report, again it brings back the correct data, what I am trying to do is show the figures from the subreport via a variable against the figures in the main report.

This will enable me to compare company averages (generated against in the subreport) against the store averages (generated in the main report).

Cheers

Marc
 
Sorry, it would seem I've got slightly confused.

I've re-read the messages a few times now and I'm sorry if I've confused the issue slightly.

You have to place the Variable within the sub-report where it will show the result you wish to return to the Main report, i.e. if you want to show the first record of the subreport data, then place it in the subreport header, if you want to return the last record, place it in the subreport footer etc. etc.

Does this make better sense?

Reebo
Scotland (Sunny with a Smile)
 
What does this mean?:

"what I am trying to do is show the figures from the subreport via a variable against the figures in the main report."

Provide example data and expected output and you'll likely get immediate results.

-k
 
I'm getting confused myself!

What I want to display is something like

Store Sales Company Sales
Suits
Hugo Boss 24% 32%
Pierre Cardin 76% 68%

The report is grouped so the percentages appear in Group Header 3 in the main report. The Store sales are generated by the main report.

The Company Sales are generated in the sub-report. I did this so I could work out the figures company wide and don't need the store group I have in the main report.

I then want to show these percentages side by side.

The variable appears in Group Header 3 in the main report and Group Header 2 in the sub report.

Does that make thinks clearer or cloud the issue even more?!?!?!?



Cheers

Marc
 
OK, go into sub-report links again and, for both link items, in the bottom left hand corner click on the down arrow and goto the top of the selections.
You will see {?pm-?suit selection} and {?pm-?season start date}. You should be linking via these.

Try it and let me know what happens.

Reebo
Scotland (Sunny with a Smile)
 
I am linked on that and all I get is the bottom value from the Sub report appearing against every record in the main report.

Cheers

Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top