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!

How to Limit a Record Return in a Main Report by a Subreport

Status
Not open for further replies.

Garyjr123

MIS
Sep 14, 2010
139
US
Basically, I have a maine report that is set up with two subreports. One in a GH and the other in the details section. I'm wondering if there is a way to suppress or do a record selection on the results of the subreport in the details section.

If the subreport in the details section shows "---" then I want to return these records only in the main report. I did an if, then, else formula to show a different string based on the results.

if {practproauthlist.has_resmap} = 1 and {pro.has_resmap} = 0 then "Pract Map"
else
if {practproauthlist.has_resmap} = 1 and {pro.has_resmap} = 1 then "Pract Map"
else
if {practproauthlist.has_resmap} = 0 and {pro.has_resmap} = 1 then "----"
else
if {practproauthlist.has_resmap} = 0 and {pro.has_resmap} = 0 then " "

Thank you,

Gary
 
Is this formula in the subreport? Are you saying you want to suppress results in the main report if the subreport formula shows "---"?

Please clarify.

-LB
 
Hey LB,

Yes, the formula (@PractProMap) is in the subreport and I want to see results that have "----" and nothing else.

Gary
 
I'm assuming you mean you want to see the main report fields ONLY if the sub returns "---". Insert another detail section and move the sub to detail_a. You can format detail_a in the main report section expert to "underlay following section" if you want it to appear aligned with detail_b. Then in the sub, change your formula to:

whileprintingrecords;
shared stringvar x := "";
if {practproauthlist.has_resmap} = 1 and
{pro.has_resmap} = 0 then
x := "Pract Map" else
if {practproauthlist.has_resmap} = 1 and
{pro.has_resmap} = 1 then
x := "Pract Map" else
if {practproauthlist.has_resmap} = 0 and
{pro.has_resmap} = 1 then
x := "----" else
if {practproauthlist.has_resmap} = 0 and
{pro.has_resmap} = 0 then
x := " ";

In the main report->section expert->detail_b->suppress->x+2, enter:

whileprintingrecords;
shared stringvar x;
x <> "----"

-LB
 
LB,

I did as you said:

In the subreport's formula

whileprintingrecords;
shared stringvar x := "";
if {practproauthlist.has_resmap} = 1 and {pro.has_resmap} = 0 then
x := "Pract Map" else
if {practproauthlist.has_resmap} = 1 and {pro.has_resmap} = 1 then
x := "Pract Map" else
if {practproauthlist.has_resmap} = 0 and {pro.has_resmap} = 1 then
x := "----" else
if {practproauthlist.has_resmap} = 0 and {pro.has_resmap} = 0 then
x := "";

and added another Detail Section in the Main Report Db moved the subreport to Da then added the suppression formula to Details Db (x+2):

whileprintingrecords;
shared stringvar x;
x <> "----"

but the report showed the same results as the original report without your formulas. What did I do wrong?
 
Did you suppress or hide details_a or the subreport?

-LB
 
No I didn't; both details_a and details_b are not suppressed. The main report looks like this:

GH1 service.abbr
GH2 appt.start_datetime (suppressed)
GH3a appt.appt_id (not suppressed with multiple table.fields)
GH3b (subreport) Procedures.rpt
Da (subreport) pract_pro_map.rpt (not suppressed and has the formula we are trying to limit the results on)
Db x+2 formula (not suppressed)
GF3 (suppressed)
GF2 (suppressed)
GF1 (suppressed)
 
You enter the suppression formula in the section expert->details_b->suppress->x+2.

-LB

 
I did, I right clicked on details_b then clicked on Section Expert, clicked on x+2 in suppress(for details_b) and entered the formula. Nothing changed in the report when I ran it.
 
I am assuming the sub is linked to the main report on some field that is unique to the detail section--correct?

Please add a formula to detail_b to test whether the shared variable is passing:

whileprintingrecords;
shared stringvar x;

Then report back with the result.

You could also try changing the beginning of the formula in the sub to:

whileprintingrecords;
shared stringvar x; //(removing the := "")

-LB
 
LB,

The only thing in detail_a is the subreport. There are no other unique fields in details_a to link the subreport to. I linked the subreport to two fields within the main report that are not necessarily in the report.

Gary
 
Please explain what happened when you added the test formula to the main report. Also explain whether changing the shared variable formula by removing the initial value of x ("").

A subreport doesn't have to be linked, but I assumed that you were trying to return some value that was unique to the main report row. Please identify the field you are grouping on in the main report. Also identify the fields you used to link to the subreport and explain why you are linking on them.

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top