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

One Day I will get the hang of this!!

Status
Not open for further replies.

pomster

Technical User
Jan 15, 2003
88
AU
CR10, Passing variables from subreports, I have a subreport in GF3 and have a variable Invvalvar1 to pass to the main report and summarise in GF2 (and GF1). I have created 3 formulas as follows:

//formula1
WhilePrintingRecords;
Shared NumberVar Invvalvar1;
NumberVar Invvalvar1Total;
Invvalvar1Total := Invvalvar1Total + Invvalvar1;

//formula2
WhilePrintingRecords;
NumberVar Invvalvar1Total;


//formula3
WhilePrintingRecords;
NumberVar InvValVar1Total := 0;

I cannot seem to get the required result.

Q1, where do I place the formulae?

Q2, Is there any documentation that I can use to get this to sink in my thick head rather than bothering you guys each time I get stuck?

kind regards,


David


 
Do you want to display the subreport, or simply pass the value to the main report? Does your subreport have groupings?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
'Formula 3' clears the value. Put it in GH2, or else in a lower section of GF2.

'Formula 1' accumulatest values passed back from the subreport. You will need to put it in a section below the section that has the subreport.

'Formula 2' shows the result. That should go in GF2.

It might also be better to split the functions of 'Formula 1'. Have just
Code:
WhilePrintingRecords;
Shared NumberVar Invvalvar1;
Invvalvar1
Then accumulate this value as if it was a normal value.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Guys,
Is this what you are saying? if so still no joy!!
Subreport is visible, detail only

GH1
-----------------
GH2 @formula 3
-----------------
GH3
-----------------
Detail
------------------
GF3a Subreport Detail Section only variable in report footer
------------------
GF3b @formula 1
------------------
GF2 @formula 2
------------------

cheers,

David
 
I don't know - unless you haven't put a formula in the subreport. If that's the problem, here's how to fix it.

For a date, put a formula field in the subreport like
Shared dateVar
V_Today := {LoadStatus.LastDLoad}
To access it in the main report, create another formula field with
Shared dateVar
V_Today := V_Today

If it was a currency value, you'd do it differently, e.g.
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:={#TotSaved};
SumSaved
And to access it in the main report, create another formula field with
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Make sure you have placed the subreport shared variable somewhere on the subreport canvas, and that you have used "shared" before the variable name. Also, instead of saying something doesn't work, please say what your results are. What values appear for the formulas in the main report?

I think it would help if you copied your formulas (all four) into the post.

-LB
 
OK this is what I have at the moment,
my variable in subreport is as follows:

Shared numberVar InvValVar1 :=Sum ({@SplitInvoiceVal});
other formulae as above and placed as below

GH1 SALESMAN
-----------------
GH2 DATE BY MONTH @formula 3
-----------------
GH3 NEW/EXISTING BUSINESS
-----------------
Detail
------------------
GF3a Subreport Detail Section only variable in report footer
SHARED DEALS, USING SAME DATA AS MAIN REPORT LINKING {SHARED WITH} FIELD TO {SALESMAN}, DATE BY MONTH AND BUSINESS TYPE
------------------
GF3b @formula 1
------------------
GF2 @formula 2
------------------

now to try and explain the symptoms,
Not all instances of subreport contain data, these are suppressed.
On the first subreport instance,Salesman 1, April - 04, the variable is passed to the main report with the correct value. This value then continues to be shown in Formulas 1 & 2 until Salesman 2, Jan - 05 New Business (1st record for salesman 2)where both F1 and F2 double. Then, in Salesman 2 Feb - 05 it goes back to the original value. It then alternates between single value and double by month until the second subreport instance, Salesman 3, Jan - 05, where the variable is summed and then off we go again.

I am confusing myself with this and probably you!!

thanks for your time so far,

regards,


David



 
Try adding the following reset formula to GH#3 in the main report:

whileprintingrecords;
shared numbervar InvValVar1 := 0;

If you have null subreport values, the previous values will carry forward and get accumulated unless you reset the shared variable.

-LB
 
LB,

The plot thickens!!

now I have both F1 & F2 accumulating at the next instance of the subreport and not resetting.

cheers,

David
 
David,

Post all of the formulae you're using. At the moment, all anyone trying to help you can do is best guess you. I'm positive the solution here is pretty simple, but the quickest way to get that is to present all the info you can.

Cheers,

Naith
 
pomster, if you want to stop a total accumulating, insert something along the lines of your original Formula 3 to zeroise it. Put it in the group header, maybe.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
I think you might be getting confused by observing the results of formula1 instead of formula2 (which is the actual display of the results). I just reread your original post, and you seem to want results at two different group levels, so let's start over again. Change formula1 to:

//{@formula1} to be placed in the Group#3b footer and suppressed:
WhilePrintingRecords;
Shared NumberVar Invvalvar1;
NumberVar Invvalvar1Grp2Tot := Invvalvar1Grp2Tot + Invvalvar1;
Numbervar Invalvar1Grp1Tot := Invalvar1Grp1Tot + Invvalvar1;

//{@formula2} to be placed in the Group#2 footer:
WhilePrintingRecords;
NumberVar Invvalvar1Grp2Tot;

//{@formula4} to be placed in the Group#1 footer:
WhilePrintingRecords;
NumberVar Invvalvar1Grp1Tot;

//{@formula3} to be placed in the Group #2 header and suppressed:
WhilePrintingRecords;
NumberVar InvValVar1Grp2Tot := 0;

//{@formula5} to be placed in the Group #1 header and suppressed:
WhilePrintingRecords;
NumberVar InvValVar1Grp1Tot := 0;

//{@reset} to be placed in the Group #3 header and suppressed:
whileprintingrecords;
shared numbervar InvValVar1 := 0;

-LB
 


Thanks LB, it's now working at the Group 2 level, however, Group 1 is showing zero. Sorry to be a pain!!

cheers,


David
 
LB,

Found the error, not enough V's in formula 1. Thanks for your, and everyone else's input. You have been a great help.

Regards,


David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top