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

formula results one row off 1

Status
Not open for further replies.

jdeejay

Programmer
Oct 5, 2001
44
US
I am summing two variables from subreports. The correct result is returned on the next line instead of where i intended. how to force it to the correct line?

advance thanks
 
Sometimes this happens when the formula reads before the subreport runs each time. If so, try this. Split the section into A and B subsections. Put the subreport in A and the formula that retrieves the number from the subreport in the B section. You can then underlay A to get them back to side by side. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks for the response Ken.

I tried that, but it didn't work for me.
In each subreport, I declared a shared variable and assigned it (in the details of sub) the current value of result from a stored procedure. In the main report, I have a formula in the details that names those same two variables and add them together in a third variable. But the result appear one line lower than it should.

Is this the correct approach, or have I made a gross error in how to do this seemingly easy task.

thanks again,
john
 
In Which section is the subreport located?
The subreport is only going to pass one shared variable value for each variable, each time it is run. Therefore, I don't think it makes sense to assign the variable in the subreport's detail section. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
The subreport is located within the details section of the main report and is returning a number that was calculated in a stored procedure called in the subrpt. I have a separate formula with a different shared variable that I am using in the main report's row sum. It is assigned the current value in the subrpt. So I have two formulas with two diff shared variables in the subrpt. One I use to return the value to my table and the other I use to do a sum. Is this not the way to do this, is this too convoluted.

Essentially what I am trying to do is make a table. I want all columns in the table to report off the names in the first column. The last column needs to be a sum across a row and the last row needs to be sums of the columns. The names in the first column come from a select distinct query of the main report and those names are then passed to the subreports which pass that name along with a date range to a stored procedure that returns some value. The correct values are being returned and they line up correctly with the name in Col 1. I can sum the columns, but that darn row sum is off.

Thanks,
John
 
What is the formula used for the row sum?

What are the other formula field names in that row; the ones that are added together to make up the row total.

You probably don't need shared variables to add the columns together for row total. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Ken,
this is what I have to do the sums

in main report details
@row_total
whileprintingrecords;
shared numbervar senttotal;
shared numbervar recdtotal;
shared numbervar rowtotal := senttotal + recdtotal;

in subreport1 details
@sent_total
shared numbervar senttotal := {SP_ETS_SENT.ETS_SENT};

in subreport2 details
@recd_total
shared numbervar recdtotal := {SP_ETS_RECD.ETS_RECD};

Thanks,
John
 
Try this:

1) Split your details section into Details A and Details B
2) Put both subreports in Detail A
3) Put the Row Total Formula in Detail B

Is the Row Total formula now correct? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken,
No, that didn't work either. If you meant to use underlaying, I tried that as well, but still no luck. I don't understand why the correct value shows up one row later. Can I use the EvaluateAfter() somehow?

Thanks,
John
 
Evaluate After only works when 2 formula are in the same section of the SAME report, not across subreports. The way to force the formula to evaluate after the main report, is to but it in a later section. How many records is each subreport reading to get the value stored in the variable? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
The value stored in the variable is returned from a stored procedure. The stored procedure is reading thousands of records, doing some calculations and returning a single value.

John
 
If that is the case, why is the subreport formula on the detail band of the subreport? It may not make a difference, but if you only need one value from each subreport, the formula should be in the report header or report footer of the subreport. The details of the subreport should be suppressed. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I am pretty new to CR, so maybe I am not explaining correctly.

The subreport is in the details of the main because I need it to be called for every item in the first column.(I am passing what is there to the subreport to use in its call to the Stored procedure). The subreports have a stored procedure result in the details because I was doing a manual running total. But, I have stuck the results of the stored procedure in the footer of the subreport and it doesn't affect the outcome.

John
 
You have taken on a challenging assignment for someone new to Crystal. I am afraid that for me to troubleshoot this question further would require more effort than I can devote to a Tek-Tips thread. You might want to consider getting an expert to look at the report to see what is wrong. There are several experts here (you can tell by looking at our signatures) who are also available for rent. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Ken,
I certainly appreciate the time you did spend trying to help me with this one. I have been gaining alot of ground with CR by searching this site for information, and have seen your responses many times.

I think what I am trying to do is get around having to "hard code" (populate) a parameter list. I wanted all other information in my table to come from a dynamic list in the first column. And I definitely need to use SProcs. I am looking at expanding the stored proc to just go get all this stuff and make it much easier for CR. It was so close.

Thanks again,
John
 
And I am pretty sure there is a solution, if you have all of the numbers on the page. There are just too many variables to tease out here in TT. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top