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

Reset on summary sub report 1

Status
Not open for further replies.

taterday

Programmer
Jan 28, 2009
183
US
I have a subreport that produces its own data.

DateFrom_Shared and DateTo_Shared are from the Main report. This works.
Group is set to employeeid. The employeeid is linked to the main report and is working.

Detail: is supressed since I only wanted totals to print. this works.
Detail section:
Hours_Daily_Charged
numbervar Hours_Daily_Charged_Total;
if ({TE.TEDate} >= {@DateFrom_Shared} and {TE.TEDate} <= {@Dateto_Shared}) then
Hours_Daily_Charged_Total := Hours_Daily_Charged_Total +{TE.TEHours}
else
0

GF1 Section: Display_Hours_daily_charged variable

Whileprintingrecords ;
numbervar Hours_Daily_Charged_Total ;
Hours_Daily_Charged_Total


GH1 Section: Reset_Hours_daily_charged

Whileprintingrecords;
numbervar Hours_Daily_Charged_Total;
Hours_Daily_Charged_Total := 0


If there is no value, 0, in the last record for the group, the total is right. I am adding the last value into the total. I have even tried adding a group I did not need below my group to do the reset there.

Please I need help.

 
Use shared variables to pass details back. In the subreport, have something like
Code:
Shared StringVar 
if (item#}=0
AllDone := "Y"
To access it in the main report, create another formula field with
Code:
Shared StringVar 
Choice :=  AllDone
Check for @FromSubreport = "Y"
Note that the shared variable is only available in the section after the section which contains the subreport.

You might also manage it by changing the variable you have to 'shared'.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Also you will need to start all formula using or evaluating a Shared variable with

whileprintingrecords;

Ian
 
You didn't really clarify the problem, but I think your detail level formula should be:

whileprintingrecords;
numbervar Hours_Daily_Charged_Total;
if ({TE.TEDate} >= {@DateFrom_Shared} and
{TE.TEDate} <= {@Dateto_Shared}) then
Hours_Daily_Charged_Total := Hours_Daily_Charged_Total +{TE.TEHours};

-LB
 
I don't think I explain my problem. Sub-report: I am adding in the data from the last record twice. I was using sum when it was a separate report. I do use shared when I am passing the data between reports. Do I need to use shared from the results are only needed on the report that I am processing?

I don't need to use the total in the main report. This is a separate report that could stay alone. The user wants to see the info on the same page with the main report. The reports, the main and the sub-report used to be 2 reports. They wanted them combined to get the results on 1 page. Short reports.

 
Are you saying that the last record is INCORRECTLY being added twice? If so, it sounds like you have a copy of your accumulation formula in the group footer by mistake.

-LB
 
Yes, when I don't suppress the detail line, the total that is wrong is always the result of the lastrecord on the detail line being added twice. If there is a zero value on the lastrecord for one column, the answer is correct. If there is a numerical value on the lastrecord in one column, the answer is off by the lastrecord value. If it is 10, then the total is off by 20. If it 3, the total is off by 6.

I couldn't find the extra variables. I have 4 total fields on the report and the same thing is happening. I thought it would be easier to explain using one of the fields. What I am doing wrong is wrong with all of them.

Thank you, please.
 
Does the subreport provide correct results when you run it by itself?

I think we need to see the content of your shared date formulas. Also please explain in what main report section the subreport is located. The subreport needs to be in a section below the one where the shared variable is set up in the main report (not in the same section).

-LB

 
Yes it did. But the totals had to be changed from the sum to calculating totals. The shared variable had to be added to pass the first prompt to the subreport. It does filter the date right and the link to the employeeid is working. It only prints the employee that relates to the main report. I pulled the data using SQL and the data is being extracted correctly.

The only shared variables are the date range that is working. I name my variables their purpose.

Info requested.
Main report the subreport is in GF+1b TE.Employeeid

Sub report.
GH1a has the report heading
Gh#1b has the Column heading. The total resets totals are here and suppressed.
Details has the variable adding and this is section is suppressed.
GF#1a printing the totals Display_Hours_Charged
GF#1b has the reseting of totals and is suppressed.

Hopefully this is what you needed to help me.



The

 


Hours_Daily_Charged:

Whileprintingrecord; was added did not help.

numbervar Hours_Daily_Charged_Total;
if ({TE.TEDate} >= {@DateFrom_Shared} and {TE.TEDate} <= {@Dateto_Shared}) then Hours_Daily_Charged_Total := Hours_Daily_Charged_Total +{TE.TEHours}
else 0
 
That was not what I was asking. I am asking if you execute the current subreport by itself whether you get the correct results (providing the parameter values yourself).

Please comply with my questions, including showing the formula content. I need to understand where the date values are coming from. Also, please identify the groups in the main report--the fields you are grouping on.

-LB
 
That was not what I was asking. I am asking if you execute the current subreport by itself whether you get the correct results (providing the parameter values yourself). Please, I am trying to do what you say. I am sorry. Sometimes I don't know how to do what you ask.

I execute it by itself by manually adding the dates and still got the add on the lastrecord twice.

DateFrom_Shared and DateTo_Shared values are being sent from the Main report. Only the records that match these dates are being processed. Group is set to employeeid in both the main and subreport. The employeeid is linked from the main report to the subreport.

Detail: is supressed since I only wanted totals to print.

GH1 Te.Employeeid group section:
code in Reset_Hours_daily_charged

Whileprintingrecords;
numbervar Hours_Daily_Charged_Total;
Hours_Daily_Charged_Total := 0

GF1 Te.Employeeid group section:
Code in Display_Hours_daily_charged

Whileprintingrecords ;
numbervar Hours_Daily_Charged_Total ;
Hours_Daily_Charged_Total




 
Please show the content of these formulas: {@DateFrom_Shared} and {@DateTo_Shared}.

In what report section of the main report is the subreport located?

-LB
 
Report section on the main report the subreport located? GF#1b
employeeid group linked to the subreport by employeeid

Retrieves data from a SQL database interfacing with an apps that supplies the prompts. I look at the file in SQL using the same filter.
It is the lastrecord for that employeeid that is adding in twice.

Main report

fielddateFrom_split
shared datevar shared_datefrom ;
stringvar Array myFilter1;
evaluateafter( {@obtaindata});
filter1[1];
stringvar array x := split(myFilter1[1]," to ");
shared_datefrom := date(x[1]);
shared_datefrom


contents of the datefrom_shared in subreport

Whileprintingrecords;
Shared datevar shared_datefrom;
shared_datefrom

 
I still need more info. Where is this formula located in the main report? What is the content of {@obtaindata}? Is the myfilter1 set in the other app? I think the problem is coming from an evaluation time issue that is related to the placement of these items or the nature of the formulas.

-LB

 
I got it working! I moved the date_shared variables to detials and reworked my formulars.

thank you for hanging in there with me.

You deserved the gold star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top