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

Calculation CANNOT be done when Passing parameter from Subreport!!!!!!

Status
Not open for further replies.

sommererdbeere

Programmer
Nov 20, 2003
112
US
Hi,

i have trouble doing calculation when parameter passed from subreport to main report.

version: crystal 8.5
database: oracle 8.0

main
grp footer OrderNo_1a: cur_wip received_val_subreport
grp footer OrderNo_1b: total_cost

subreport
grp footer OrderNo_1a: received_val

i shared received_val from subreport to main

i tested the total_cost, in the formular, i put {received_val}, which it shows and i put {cur_wip}, this is from main report directly, it shows as well.
However, if i tried to add it together as {received_val}+{cur_wip}, nothing shows.

does any experts here know why?? i've tried to figure out for a long time, but i can't find any solution. I hope anyone can help me on this. thank you very very very very much.

m

 
First, this isn't a parameter, and you might confuse people using that term, it's a shared variable.

Next, don't use text to state what you tried, post the formulas that you tried, where, and what the actual results were (does it return 0, null or a wrong answer?).

To put it in terms that you prefer, this does work and is commonly implemented.

In technical terms:

In the subreport use something like:

shared numbervar MyNum := 100

In the main report group header use:

shared numbervar MyNum := 0

Then in the main report AFTER the subreport has fired, try:

shared numbervar MyNum

You may be experiencing problems because the main report doesn't have data for some group that the subreport does.

Hard to say as you've provided very little technical information.

This should help you resolve it though.

-k
 
Be sure to place the formula for the shared variable somewhere on the subreport canvas, and in both subreport and main report formulas you must use "shared numbervar" preceding the variable name as SV shows.

-LB
 
thanks synapsevampire ,

i hope this will understand better..


i have a main report and a subreport. for the subreport, i want to get {received_val}. in the main report, i have a valuable called, {cur_wip}. i need to calculate total_cost by adding those 2 together {received_val}+{cur_wip}. however, nothing comes out; meaning blank.

if i have total_cost = {received_val}, it shows.
if i have total_cost = {cur_wip}, it shows.
if i have total_cost = {received_val}+{cur_wip}, blank.

example for when total_cost = {received_val}:

received_val cur_wip total_cost
9583.30 320 9583.30

example for when total_cost = {cur_wip}:

received_val cur_wip total_cost
9583.30 320 320

example for when total_cost = {received_val}+{cur_wip}:

received_val cur_wip total_cost
9583.30 320

my question is i don't know why the calculation cannot be done when i try to add it together. is there any trick to it?

i placed total_cost after subreport in main. a section after grp footer for the subreport.

many many many thanks for ur help.

if anyone have any idea, pls. help.
thank u
 
Your subreport formula should be placed on the subreport canvas and look something like:

whileprintingrecords;
shared numbervar recvalcost := {received_val};

In the main report, your {@totalcost} formula should be:

whileprintingrecords;
shared numbervar recvalcost;

recvalcost + {cur_wip}

Just because you can see a value from the subreport in the main report does not mean that it is a shared value, unless you take these steps.

-LB
 
You aren't showing what formulas you are using or where, so it's hard to help. You also don't show where you're displaying these values. I had asked for this information, and it's required to understand the requirements to assist you.

For instance, if the subreport has a field called {received_val}, you can't reference it directly in the main report, you must create a formula as in my example and declare a variable as shared for the main report to use it.

If you want to just post text describing a problem, technical forums aren't a good place, try a chat room. If you want quality technical advice, supply technical information, such as:

RH
PH
GH1 formula to reset the shared variable
Det
GF1A Subreport firing
GF1B Formula to acquire and display the subreport value plus group value
RF

Just in case you don't know what a formula is, use Insert->Field Object->Right click formulas and select New

In my previous post I referenced:

In the subreport use something like:

shared numbervar MyNum := 100

In the main report group header 1 use:

whileprintingrecords;
shared numbervar MyNum := 0

Place the subreport in Group Footer 1A

Then in the Group Footer 1B create a formula containing:

whileprintingrecords;
shared numbervar MyNum;
MyNum+sum({table.value},{table.group})

If this doesn't help, please post exactly what you're doing and where.

-k
 
hi lbass and synapsevampire,

the formular that i used is very simple, which i have wrote it earlier:

for {@total_cost}
shared numbervar received_val;
received_val + {cur_wip}

i placed the formular under subreport, Group Footer 1B, which i placed my subreport in the grp section: Group Footer 1A.

thanks for your advice as it FINALLY WORKS!!!!!!!!! :__(
sooooooo happy :))))))))))))
i think the reason it doesn't work, because i didn't have received_val + sum({cur_wip},{ord_no}).


thank u to both lbass and synapsevampire.. thank u thank u.. thank you synapsevampire for your valuable advice and suggestions.. thank u

m




 
but i have 2 questions:

1. why do you use whileprintingrecords?
2. how can i do grand total for a formular?

i created the formular as {@total_cost}, which i try to do
sum({@total_cost}) for the grand total, but it doesn't allow me to. it pops up warning sign that said, "summary/running field cannot be created".

do any of you have idea as to why this happen? if so, any idea?

million thanks
 
Change your formulas to something like:

//{@reset} to be placed in the group header for ord_no:
whileprintingrecords;
numbervar subtot := 0;

//{@accum} to be placed in the ord_no group header (in a section below where the subreport is):
whileprintingrecords;
shared numbervar received_val;
numbervar subtot := received_val + sum({cur_wip},{ord_no});
numbervar grtot := grtot + subtot;

//{@displaysubtot} to be placed in the group footer for ord_no:
whileprintingrecords;
numbervar subtot;

//{@displaygrtot} to be placed in the report footer:
whileprintingrecords;
numbervar grtot;

-LB
 
am i goning to add a section below group header section for order_no for the {@accum}?

i tried it, but it doesn't work. it seems like it is pulling out {cur_wip} and accumulated it, but it didn't take the sum of received_val + sum({cur_wip},{ord_no}).

do you have any idea as to why this happen?

thank u very much for ur help
 
I don't know where the subreport is. If the subreport is in the group header section, then insert two more group header sections, and put {@reset} in GH_a, put the subreport in GH_b, and put {@accum} in GH_c--the section below the subreport. Put {@displaysubtot} formula in the group footer. The accumulation formula itself will only show the value of the grand total as it accumulates, and you can suppress it so that it doesn't display. The subtotal display formula will show the result in the group footer. The grand total display formula will show the total in the report footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top