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

how to use a shared variable from main report to sub report <URGENT>

Status
Not open for further replies.
Mar 5, 2003
4
PH
hi, im using crystal 8.5 and i want to use my shared variable from my main report formula to my sub report. My report is to get the vessels in a day. For example:
Parameter Date: 06/15/2005
Return Value of Vessel should be: GIRALDA
KOHFU
MEDINA
The syntax of my formula on how to get the vessel:
formula {@xvessel}
shared vessel as string
shared a(1) as string
shared i as number

i = 1

do while i = 1 to {@display}
if {view_Prod_Today.Date1} = {?Date} then
redim preserve a(i)
a(i) = {view_Prod_Today.Vessel}
vessel = a(i)
formula = vessel
end if
i = i + 1
loop
--MAIN REPORT--
GroupHeader1 - Date
GroupHeader2 - Vessel (I inserted my {@xvessel} formula here in group header 2 and it returned the value of GIRALDA, KOHFU and MEDINA.

Now, how can I used this to my subreport. My subreport is to display the value of boxes produced based on the result of vessels from main report. For example the above date parameter: 06/15/2005 and the return vessel of that date are GIRALDA, KOHFU, MEDINA. I will get the summary report of that Vessel from that current date backward until their vessel is equal to the current vessel of main report?
Ex.
06/15/05 - GIRALDA, KOHFU, MEDINA >>>> this is the current
date
06/14/05 - LERIDA, KOHFU, GIRALDA,
06/13/05 - GIRALDA

Therefore, I will get the boxes produced from the current date(6/15/05) and then check if date(6/14/05) have vessel equal to current date. if its equal get again the boxes produce.

 
Shared variables are usually used to move data from a subreport back to the main report. If I've understood you correctly, the 'shared variable' is worked out in the main report and could be just a 'variable'.

To move data from main to subreport, check edit > subreport links. Find something to link the main-report field to - not that this will create a selection rule in the subreport's record selection, though this can be removed if you don't want it.

Once you've made the link, the main-report field will be visible from the subreport.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
I'm not sure why you are using the date group in the main report. Couldn't you use the parameter to limit the records in the main report to the particular date, and then group on the vessels that meet that criteria?

Then without using shared variables, you could simply link a subreport to the main report on {table.vessel} and place the subreport in the group header. This would then show all shipments by that vessel regardless of date.

-LB
 
---TO: LBASS----

In my main report my parameter is only the transaction date. If I input a parameter date 06/15/05 the result of the vessel should be: GIRALDA, MEDINA, KOHFU.

I link the parameter date to my subreport date but how can I get or use the following vessel in my subreport?As of now the result of my subreport displays the other vessels because in my subreport it is a summary of the current date transaction backward to 7 days. So other vessels are included even if its not equal to the result of vessel from my main report. For example:

--main report output--
parameter: 06/15/2005
result/vessel: MEDINA, GIRALDA, KOHFU

--subreport output----
parameter date from main report link to subreport:
06/15/2005
result of vessel should be also the same from main report.
Now, the subreport should displayed not only the 06/15/05 data but it will display also the 06/14/05 data which are the vessel : MEDINA, LERIDA, GIRALDA, KOHFU. So in this case I will only pick the data from date 06/14/05 base on the vessel dated on 06/15/05 bcoz that is my main parameter. So how can i do that in my subreport?



 
I would create the parameter within the subreport also, and then link the two date parameters by using the dropdown in the bottom left of the linking screen to choose {?date}, not {?pm-?date}. In the subreport, use {?date} in the record selection criteria like this:

{table.transactiondate} in {?date}-6 to {?date}

...assuming you want dates for a 7-day period.

I think you should also group on vessel in the main report instead of using your looping formula, and then link the subreport to the main report on vessel, also, since it seems that you want a summary per vessel. If you also want a summary across vessels, you could creata a shared variable in the subreport, and then accumulate it across vessels in a main report formula. I am unclear what you want your final result to be.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top