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

Shared Variable called for here? 1

Status
Not open for further replies.

Bennie47250

Programmer
Nov 8, 2001
515
US
I need to suppress a Details B section on a main report based off a value on a subreport.

Is the best way to do this a shared variable? Have the shared variable to be the value on the subreport that I want to use to do the suppressing?

Tips on how to do it this way or another way will be appreciated.

Thanks
 
Need to supply some missing information. Where is the subreport and how is it linked?

For one, the subreport has to be located before Detail Section B.

In the subreport, you need to set up a shared variable

Code:
shared booleanvar suppressit := false;
if {table.field}= "somevalue" then
  suppressit := true

Then format detail section B and and check on Suppress box and click on the x+2 button and add the following formula

Code:
shared booleanvar suppressit;
suppressit;

-LW
 
I had planned on putting the subreport in Details section B.

The subreport is linked to the main report by a field named SerialNumber

In the subreport there is a Quantity field, I was planning on doing a total of this field and if the total = 0 then suppress the section.

Based on kskid response I suppose I can’t suppress Details section B with a value that is in Details section B. How would one work around this?

Thanks
 
When using a shared variable between the subreport and main report is that the shared variable from the subreport is not available for use until the next section of the main report.

So id you place the subreport in detail B, the shared variable can be used in Detail Section C and below

So, in your case, the subreport has to be placed in Detail A if you have room. Or you can insert anther detail section below A, which will move the old Detail Section B to Section C

You should be able to suppress all sections in the subreport and still get the shared variable updated.

If you placed the subreport in Detail A, then use the above formula to suppress Detail B

If you inserted a new detail section B, then from the main report, make the subreport as small as thin as possible, vertically.

Also make the new detail section B containing the subreport as small as possible and under lay it with detail section C (or old detail section B). Use the above formula to suppress detail section C

-LW
 
Well I’m still having problems.

What I have done is made a copy of my subreport and renamed it to NCPwithVariable.

To this report I added the variable as described
It is named “SuppressNCP” and the formula is

shared booleanvar suppressit := false;
if Sum ({NCParts.QTY}) <> 0 then
suppressit := true

The variable was placed in the report footer and it reads true if NCParts.QTY is greater than zero.

This subreport was placed in Details Section B.

On the main report I created the formula named “SupressNPC” and the formula for it is:

shared booleanvar suppressit;
suppressit;

This formula was placed in Details Section C and it shows True or False as appropriate. However if I suppress Details Section B, it always shows false.

It’s like if Details Section B is suppressed, the variable is not being evaluated. Does the section have to be visible for the variable to be evaluated?
 
DO NOT suppress Detail section B or the subreport. Otherwise, the shared variable never gets evaluated.

Also, the formula in the subreport is wrong
Code:
shared booleanvar suppressit := false;
if Sum ({NCParts.QTY}) = 0 then
  suppressit := true

On the main report under the report design tab, right click detail section C on the left. Click on Suppress box and click on the x+2 button and enter the following formula

Code:
shared booleanvar suppressit;
suppressit[code]

Explanation: 

If the sum of the subreport is 0, then suppressit is true.

In the main report Detail section C (which is suppressed) and suppressit is true, then detail section remains suppressed.
 
So close yet so far.

I just can't seem to get this to work for me.

I have changed the formula in the subreport and added the additional code to the x=2 in the suppress but it is now suppressing when I don't want it to and showing things I don't what to show.

grrrrrrrrrrr
 
Is the value of suppressit correct when the sum is 0? Is Detail Section C suppressed? If your answer is yes to both, then Detail section C will remain suppressed
 
I have made modifications to kskid code and I'm now getting the desired results.

The subreprt shared variable is now:

shared booleanvar suppressit := false;
if Sum ({NCParts.QTY}) <> 0 then
suppressit := true

Apparently I don't need a shared variable formula on the main report

On the details section c I using:

shared booleanvar suppressit;
suppressit = false
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top