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!

can't reset variables between groups

Status
Not open for further replies.

bobalou

Programmer
Dec 8, 2003
17
US
i am trying to pass sums from two different subreports up to the main report level and then add them to a value in the main report which is a sum within a group. i can get the value up to the main report using the following in the subreports (other uses different variable in same formula)

whileprintingrecords;
shared currencyvar sum_curr_bid := Sum ({workord.wo_curr_bd}, {@lpst_to_num})

then i put a new formula (sum_curr_bid + sum_curr_bid2) in the main rpt details section that sums the two subreport values ok except that is shows up in the next group rather than in the current one, and i cannot get it in the correct group, or cannot reset it to 0 or blank by putting a formula in the header or footers of the main report group as suggested in one of my books.

when i try
whileprintingrecords;
shared currencyvar sum_curr_bid := 0

or
whileprintingrecords;
shared currencyvar sum_curr_bid;
sum_curr_bid = 0

i get an error msg stating that the value must be boolean. if it is a currency variable why would it be boolean?

any help is appreciated.

tks, mike
 
Your post is a little confusing, but if I'm understanding you correctly that you have group summaries in each subreport that you want to add to a group summary in the main report, then you could try the following:

I am assuming that the subreports are linked to the main report on the group field. In the main report, insert two additional group footers. Place the subreports in group footer_a and group footer_b. Within each subreport, I assume you have a formulas like:

//{@sumcurrbid1}:
whileprintingrecords;
shared currencyvar sum_curr_bid1 := Sum ({workord.wo_curr_bd}, {@lpst_to_num})

//{@sumcurrbid2}:
whileprintingrecords;
shared currencyvar sum_curr_bid2 := Sum ({workord.otheramt}, {@lpst_to_num})

In the main report, create a formula {@sumall}:
whileprintingrecords;
shared currencyvar sum_curr_bid1;
shared currencyvar sum_curr_bid2;

sum_curr_bid1 + sum_curr_bid2 + sum({table.amt},{@lpst_to_num}) //where the last element is the main report group summary

Place this formula in the group footer_c, since shared variables must be placed in a section below the section containing the subreport in which they were created.

If you have linked the subreports on the group field, you should not have to reset any variables in the main report.

If you are not linking based on the same group field in main and subreports, please explain more about the report and subreport structures.

-LB
 
A numericvar should be fine.

ANd you neglected to state where these subreports are, if they're in the group level where the summaries are used, and fire before the variables are called, then they are available at the proper time.

An example would be to right click the group header and select insert section below.

Place your subreport in there.

Now the variable will be available in the Details or the Group footer.

Your dilema is likely the result of this.

As for it complianing about a boolean, the 2nd formula use = instead of :=, which would net an error. The first formula should be fine unless that variable is also used as a boolean elsewhere.

LB's formulas may work for you, but the above should help you understand the way Crystal handles shared variables.

-k
 
i am trying to pass sums from the subreports up to the main report in the details section to add to another value which is already summed in the database.

the subreports are within the details section of the main report and i want to add all three into one sum and put in the group footer of the main report. then reset to 0 for the next group.

the shared variables are being set in the footer of the subreport.

whileprintingrecords;
shared currencyvar sum_curr_bid := Sum ({workord.wo_curr_bd}, {@lpst_to_num})

the subreports are linked to the main report through a common id # in the database. both the main report and subreports are grouped on the id #.

p.s. i don't get the the

i don't get a boolean error if i just use the =, but i do if i try a := in the main report. the following doesn't produce an error, but it doesn't reset the variable either when i put it in the main report group header or footer.

whileprintingrecords;
shared currencyvar sum_curr_bid;
sum_curr_bid = 0

if i put the colon in front of the = i do get the boolean error.

i can send screen captures if there is a way to do so since my descriptions do not seem to be too clear.
 
The = sign is a comparison operator whereas := is used for assignment

Change

sum_curr_bid = 0

to

sum_curr_bid := 0

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top