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!

Variable Data from subreports not calculating properly 2

Status
Not open for further replies.

glthornton

Programmer
Oct 19, 2005
108
US
Hi everyone,

Crystal XI
ODBC Connction

I seem to be having a problem with one of my Immunization Reports. This report has 23 subreports running with it. The problem I am having is that the variable data that I am passing up from the subreports is being calculated and displayed in the following entry line instead of the current line.

Sample Report:
Code:
PatID    Last Name  First Name     DTaP1  DTaP2    Total
123      Test       Patient          2      1        0
234      Doe        John             1      1        3
345      Doe        Jane             0      4        2
456      Doe        Baby             0      0        4

Can anyone point me in the right direction as to how I can correct this?

Thank you,
GlThornton
 
Would you be able to show the formulas where you are passing the data back to the main report from the subreport?

Your sample output is not clear to me.
 
Sure,

Here is what I have put in as a formula field in the subreport:

Code:
whileprintingrecords; 
shared Numbervar DTapTotal := {#Total Count};
DTapTotal;

This formula is then placed in the Report Footer area which I have supressed.

Then in the main report, I have a formula field adding both the normal and historical data together. This is what my formula looks like:

Code:
whileprintingrecords;
shared NumberVar DTaPTotal;
shared NumberVar DTaPHist;
DTaPTotal+DTaPHist;

Let me know if you require any further information.

Thanks,
GlThornton
 
The main report formula that references the shared variables must be in a report section below the one in which the subreports are located. Insert another group section, e.g., GH_b, below the one in which the subreports are located, e.g., GH_a(assuming that the DTAtotal and DTAhistory fields are the dispalyed subreport footers), and then format GH_a to "underlay following sections" so that the result can be displayed in line with the other results.

-LB
 
LB,
At first I had it exactly as you had described. The only thing that I changed was to start using a Group Header. I initially was not grouping by anything in my report because I wanted data sorted by the patients Last Name, First Name. But that is okay to make some minor modifications. So I now changed everything in the format in which you described, but it is still not working. Let me try and describe exactly how I've got things put together:

Main Report:
Code:
Report Header (Hide No-Drill down)
Page Header
Group Header #1a: Patients.patid-A
Group Header #1b: Patients.patid-A
Group Footer #1: (Hide No-Drill down)
Report Footer (Hide No-Drill down)
Page Footer

Section Expert:
Group Header #1a: Patients.patid-A {Keep Together and Underlay Sections both checked}
Group Header #1b: Patients.patid-A {Keep Together and Underlay Sections both checked}

All of my data is being displayed in Group Header #1a: and my variable total formula is located in the Group Header #1b: area.
=============================================
Subreports:
Code:
Report Header (Hide No-Drill down)
Details (Hide No-Drill down)
Group Footer #1:
Report Footer a (Hide No-Drill down)
Report Footer b (Hide No-Drill down)

All of my data in these reports are located in Group Footer #1: and my shared variable count formula field is in the Report Footer a area.

If you need any further information, please let me know.

Thank you,
glthornton
 
You didn't say where the subreport is in the main report, .

If the formula is in the group footer 1b section, then you can't display that data PRIOR to it...

Nicely formatted post, but simply state where your formulas are, and where the subreport is.

If you're using a grouping, then you need a reset formula for the shared variable in the group header.

Assuming that the subreport is in the group footer a, try the following:

report header formula:

whileprintingrecords;
numbervar MyTot:=0

Place the subreport in the group footer 1a and include a formula of:

whileprintingrecords;
numbervar MyTot:=count({table.field})

In the report footer 1 b place:

whileprintingrecords;
numbervar MyTot

You should see the variable being passed. As for your method, again you need to just state a few facts, and show the formulas you are using.

-k


 
It is not clear where in the main report you have located the subreport. Can I assume it is in GH1a? When you say it is not working what do you mean? What results are you getting?

-LB
 
Thanks Syn and LB for your extremely valuable input!! And you're absolutely right, that I need to be more specific with my posts. I will definitely do so in the future. Just wish this site could post .jpg's so I could show the results.

But I did end up fixing my problem. What I decided to do is put all of my subreport totals in group header #1b: line and see if all of my totals are having the same problem. To my surprise, I found that not all of my totals were having calculation problems, only about 1/3 of them. So what I did was to delete the subreport columns that where giving my incorrect results and then re-adding them back into the main report. Once I did that, then all of my total calculations were working perfectly. This particular report that I'm working with currently has 23 subreports and building. This was the first time working with a subreport passing data up to the main report. The information which you've both provided has been extremely valuable. Thanks for being there for all of us CR users!!

GlThornton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top