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

Supress details based on detail subreport 2

Status
Not open for further replies.

Bluejay07

Programmer
Mar 9, 2007
780
CA
Hello,

I have a detail line containing an item number, description and code. The code is a subreport. Lets say the subreport will only have return values of A, B and C.

If the value obtained in the subreport is B, how can I supress the entire detail line?

Therefore, based on the results of the subreport, the detail lines should print A and C but nothing related to B.

Example:
Item, Desc, Code
123, desc1, A
456, desc2, B
789, desc3, C

Report Output:
123, desc1, A
789, desc3, C

Thank you.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Create a formula in your subreport like:
{ShareUp}
whileprintingrecords;
shared stringvar SubUp := {YourTable.YourCodeField};


Then in the main report create a formula like this:
{@SharedUp}
whileprintingrecords;
shared stringvar SubUp;


Use the {@SharedUp} in the Section Expert as the criteria for suppression of the details section: {@SharedUp} = "B"

 
i forgot to say:
In the subreport place the {@ShareUp} in the details section, next to 'code', and if necessary 'hide' it by changing font color to white.

In the main report, place the {@SharedUp} in the section next to the 'code', and also, if necessary 'hide' it by changing font color to white.

 
Thank you for your quick response.
I have tried to follow your suggestion, but all it seems to do is add several lines between the details and still displaying all detail lines.

I must not have done something correctly.
I will keep trying.

If at first you don't succeed, then sky diving wasn't meant for you!
 
I think you will need to insert another detail section, and place the sub in detail_a with everything else in detail_b. You can format detail_a to "underlay following sections". Then add the shared variable formula as fisheromacse suggested to the subreport, and and in the section expert of the main report->detail->x+2, use this formula:

whileprintingrecords;
shared stringvar SubUp;
SubUp = "B"

-LB
 
Thanks lbass for your response.
I must be doing something wrong as I still can't get this working. I'm not the most proficient in CR, but doing my best.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Linda's addition is spot on.

What results are you getting compared to what you desire?

 
I've tried several variations. Here is what I currently have.

Subreport:
Formula Field: ShareUp containing:
whileprintingrecords;

if {ICITEMO.OPTFIELD} = 'ORIGIN' THEN shared stringvar SubUp := trim({ICITEMO.VALUE});

This formula is placed in the details section.

For the main form, I have details a containing the subreport and section expert only has Underlay Following Sections checked.

Details b has all the rest of the information including the formula field SharedUp containing
whileprintingrecords;
shared stringvar SubUp;

Details a is printing every entry including all the "B"s, however details b seems to have removed all "B"s.

How do I fix detail a so that it doesn't print anything?

If at first you don't succeed, then sky diving wasn't meant for you!
 
Only the sub should be in Detail_a, nothing else. And I'm assuming the sub is only showing the field "Code".

-LB
 
Detail_a does only have the subreport and yes the sub is only showing the code.

Here is an example of the output
123a, desc *Sub Value*, A
123b, desc *Sub Value*, A
*Sub Value* <-- This would be the B
*Sub Value* <-- This would be the B
456a, desc *Sub Value*, C
456b, desc *Sub Value*, C

The sub value is displaying on every line, including the lines that are blank for the B

If at first you don't succeed, then sky diving wasn't meant for you!
 
But what is "sub value" and where is it coming from?

-LB
 
The values would be similar to this

123a, desc A, A
123b, desc A, A
B
B
456a, desc C, C
456b, desc C, C

I'm assuming these are the returned value obtained from the subreport.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Okay, I see. Instead of formatting detail_a to "underlay following seections", instead format it to "suppress blank section". Also remove the border from the sub (if you haven't already), and suppress all sections WITHIN the subreport. Then select the subreport->format subreport->subreport tab->check "suppress blank subreport". This will make detail_a effectively disappear. What you cannot do is suppress the subreport object or the section it is in.

You already have the shared variable showing in detail_b so you don't need the sub itself to show.

-LB

 
THANK YOU for your help.

Your final solution worked. If you could assist with one more item, it would be appreciated.

In addition to supressing B, what changes would need to be done to supress C as well.

If at first you don't succeed, then sky diving wasn't meant for you!
 
In the section expert->detail->suppress->x+2, enter:

whileprintingrecords;
shared stringvar SubUp;
SubUp in ["B","C"]

-LB
 
That also worked.

Thank you so much for your assistance.
Have a great day.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top