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

CR8.5- Relaying values from subreports into parent reports?

Status
Not open for further replies.

Ruune

Programmer
Jun 7, 2006
33
US
Please forgive me if this has been covered, but the search function is undergoing maintentance.

What I'm trying to do is grab a running total value from each subreport and sum them up in a parent report. Is this possible with CR 8.5?
 
You have to set the subreport value to a shared variable, as in:

whileprintingrecords;
shared numbervar rtsub1 := {#runningtotal};

Repeat for the value in the second sub:
whileprintingrecords;
shared numbervar rtsub2 := {#runningtotal};

Then in the main report, create a formula like:

whileprintingrecords;
shared numbervar rtsub1;
shared numbervar rtsub2;
rtsub1 + rtsub2;

Place this in a section below the one(s) in which the subreports are firing.

-LB
 
hmmm... what if there are a varying number of subreports?

Basically, this report grabs hospital admissions for a given date range. Then for each patient, the subreport checks the past 180 days (from the beginning date of the report) for recent admissions.
 
You need to provide more information, if you would like help, e.g., your report structure, what groups you are using, where the subreports are located (what report section), what you are trying to summarize from each subreport, and where you want to show the summary.

-LB
 
ok... here goes:

The report is grouped by patient name, then by PATID. For each ID, the subreport is launched. Parameters relayed are {PATID}, {?StartDate}, and {?EndDate}.

The selection criteria for the subreport is:
{SSVIEW_PATIENT_DATA.PATID} = {?Pm-SSVIEW_PATIENT_DATA.PATID} and
{SSVIEW_PATIENT_DATA.DATE_OF_ADMISSION} in ({?Pm-?Start Date} - 180) to {?Pm-?End Date} and
{SSVIEW_PATIENT_DATA.CURRENT_PROGRAM_VALUE} <> "PREADMIT"

Basically, for each patid it grabs the start date of the parent report and subtracts 180 days. The query then pulls all records within 180 days prior to the start date through the end date parameter.

From there, they're sorted by {SSVIEW_PATIENT_DATA.DATE_OF_ADMISSION}, in descending order.

What is being tracked from here is previous admissions within 30 days. I'm using a CrRed for inside of 30 days and CrBlue for 31-180 days prior to the most recent date of admission. Thats probably irrelevant though.

Now, I do need to count how many subreports have previous admissions within 30 days of the current admission date. However, there will be a subreport for every patient admitted within the date range parameters, and this number will vary.

Am I talking in circles here? I'm trying to fix old reports that someone else wrote back in the dark ages and plan a BOEXI rollout, so sometimes the ADD kicks in and I start thinking I'm a jedi or something. :)
 
I think you need a formula in the subreport like:

Whileprintingrecords;
shared numbervar win30days;

if {table.admissiondate} = maximum({table.admissiondate},{table.PatientID}) and
datediff("d",next({table.admissiondate}),{table.admissiondate}) <= 30 then
win30days := 1 else
win30days := win30days;

Place this in the detail section of the subreport. Be sure that the subreport is sorted in descending order by date (or change the formula to use previous() instead of next()).

You didn't say in what patientID group section the sub was located, so let's say it is in GH_b. Insert a GH_c (this section can be suppressed), and place the following formula in it:

whileprintingrecords;
shared numbervar win30days;
numbervar addwin30days;
addwin30days := addwin30days + win30days;

Then in the report footer, use a formula like the following to display the result:
whileprintingrecords;
numbervar addwin30days;

You should also have a reset formula in GH_a:
whileprintingrecords;
shared numbervar win30days := 0;

-LB
 
hmmm that looks like it'll work... thanks!

These aren't the droids you're looking for.
He can go about his business.
Move along.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top