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!

global variable problem

Status
Not open for further replies.

mrmookster

Programmer
Feb 8, 2005
27
GB
CR 8.5, SQL Server 2000, XP

i need to suppress a group if the detail section is also suppressed and i may be going about it all wrong but this is what i'm doing.

my group groups pairs of data, and i need to suppress if certain fields in the data are the same.

GH 2 // reset isSuppress flag on each new group
global booleanvar isSuppress;
isSuppress:=FALSE;

Detail // test duplication criteria
global booleanvar isSuppress;
If {#gcount} = 1
AND (Next ({_SP_CR1032;1.CLNT_MATT_CODE}) = {_SP_CR1032;1.CLNT_MATT_CODE})
AND (Next ({_SP_CR1032;1.Amt}) = (-1 * {_SP_CR1032;1.Amt}))
Then isSuppress := TRUE ;

gcount is a ruuning total counting the records in the group, I only want the condition to be evaluated on the first record in the group (ie no 1 of the pair) so we don't evaluate records in different pairs.

if the duplication is valid I set the global flag to TRUE

... what actually happens is this global var isSuppress is never changed


test output (flags only)

gcount isDuplicate isSuppress
1 True False
2 False False


maybe there's an easier way ??

thanks
 
I think you only need global variables when you are passing from a subreport to the main report. Ordinary variables are fine elsewhere.

You could have it just as a formula field:
Code:
(Next ({_SP_CR1032;1.CLNT_MATT_CODE}) = {_SP_CR1032;1.CLNT_MATT_CODE}) 
AND (Next ({_SP_CR1032;1.Amt}) = (-1 * {_SP_CR1032;1.Amt}))
Create another one, with 'next' changed to normal and normal changed to prior
These two will be boolians, returning true or false. You can then use them to suppress the detail section. (Right-click on a section and choose Section Expert. Then choose the formula icon (x+2 and a pencil) for suppression. Enter a formula

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Thanks... this is what I tried first time round. However I also need to suppress the group footer if the detail section has been suppressed.

So I tried to use the global boolean flags to allow me to do this

... unless there is another way of detecting the detail section has been suppressed within the footer.
 
You could do a running total for detail lines that didn't meet the criteria for suppression. When it comes to zero, suppress the footer.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Running totals won't work for suppressing group headers. Try using group selection instead. I'm not sure what your group field is, but if it is {_SP_CR1032;1.CLNT_MATT_CODE}, and you wanted to suppress those groups that zeroed out, then you could go to report->edit selection formula->GROUP and enter:

sum({_SP_CR1032;1.Amt}, {_SP_CR1032;1.CLNT_MATT_CODE}) <> 0

If this isn't what you mean, please specify your group field and show some sample data, so the group selection formula can be determined.

Madawc, I think you were confusing global with shared variables. If the type of variable is not specified, it defaults to global. It is the use of shared variables that is only required for passing to and from subreports.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top