Suppress individual Group Header Lines

A

Alan Z. Scharf

Hi,

Is it possible to suppress printing of individual group header lines,
depending on a condition - say the value of the group header control or the
value of another control in the group header section?

For example, I wouold like to suppress printing of Group Header B below if
value of the Group Header is B.

Group Header A
Detail 1
Detail 2
Group Header B <-- suppress printing of this group header and detail
lines
Detail 1
Detail 2
Group Header C
Detail 1
Detail 2

I know how to suppress the entire group section based on a condition, but
here I need to suppress only certain group header values.

Thanks.

Alan
 
A

Allen Browne

If you want to suppress both the group header and the detail lines, the
simplest way will be to use a query as the RecordSource of the report. Under
the field that feeds you group header, enter criteria of:
NOT 'B'
or if there are several values to suppress:
NOT IN ('B', 'G', 'X')

If you just wanted to suppress the header name and keep the detail items in
the report, you could use a text box in the group header, and set its
Control Source to:
=IIf([Field1]='B', Null, [Field1])
Set its CanShink to Yes to squash up the space.

It is also possible to use the Format event of the Group Header to set its
Visible property, or the report's runtime properties PrintSection and
MoveLayout. However, this is inferior to the techniques above as it messes
up the page count, can yield nonsense like "Page 8 of 6", and can even yield
inconsistent results if you print only some pages of the report.
 
A

Alan Z. Scharf

Allen,

Thanks very much for your reply.

1. Could you give a little more detail as to where exactly the 'Not B' would
go. In the actual control on which the group breaks? Or another field? Is
it a formula with equal sign?

An actual example would be where I want to suppress the group if the value
of the group header field = "Sharpe Ratio"

2. Another condition I also need to use to suppress a particular group
header is the following

Me.Years < 1 And Me.SortOrder > 3 Then
Suppress group header
End If

where Years and SortOrder are additonal controls in the group header
section.

The objective here is to suppress the group header if there is less than one
year's worth of data.

Thanks again.

Alan



Allen Browne said:
If you want to suppress both the group header and the detail lines, the
simplest way will be to use a query as the RecordSource of the report. Under
the field that feeds you group header, enter criteria of:
NOT 'B'
or if there are several values to suppress:
NOT IN ('B', 'G', 'X')

If you just wanted to suppress the header name and keep the detail items in
the report, you could use a text box in the group header, and set its
Control Source to:
=IIf([Field1]='B', Null, [Field1])
Set its CanShink to Yes to squash up the space.

It is also possible to use the Format event of the Group Header to set its
Visible property, or the report's runtime properties PrintSection and
MoveLayout. However, this is inferior to the techniques above as it messes
up the page count, can yield nonsense like "Page 8 of 6", and can even yield
inconsistent results if you print only some pages of the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Alan Z. Scharf said:
Hi,

Is it possible to suppress printing of individual group header lines,
depending on a condition - say the value of the group header control or
the
value of another control in the group header section?

For example, I wouold like to suppress printing of Group Header B below if
value of the Group Header is B.

Group Header A
Detail 1
Detail 2
Group Header B <-- suppress printing of this group header and detail
lines
Detail 1
Detail 2
Group Header C
Detail 1
Detail 2

I know how to suppress the entire group section based on a condition, but
here I need to suppress only certain group header values.

Thanks.

Alan
 
A

Allen Browne

1. The Not 'B' goes into the Criteria row of the *query* that supplies
records to the report (i.e. the query named in the report's RecordSource
property.) Removing the records from the query is much simpler and more
efficient than letting them into the report and trying to clobber them
there.

So, for your particular case, you would want to enter this in the the
Criteria row in query design, under the field you are grouping on:
Is Null OR Not "Sharpe Ratio"

2. Likewise, you can enter the criteria under Years and SortOrder fields in
your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Alan Z. Scharf said:
Allen,

Thanks very much for your reply.

1. Could you give a little more detail as to where exactly the 'Not B'
would
go. In the actual control on which the group breaks? Or another field?
Is
it a formula with equal sign?

An actual example would be where I want to suppress the group if the value
of the group header field = "Sharpe Ratio"

2. Another condition I also need to use to suppress a particular group
header is the following

Me.Years < 1 And Me.SortOrder > 3 Then
Suppress group header
End If

where Years and SortOrder are additonal controls in the group header
section.

The objective here is to suppress the group header if there is less than
one
year's worth of data.

Thanks again.

Alan



Allen Browne said:
If you want to suppress both the group header and the detail lines, the
simplest way will be to use a query as the RecordSource of the report. Under
the field that feeds you group header, enter criteria of:
NOT 'B'
or if there are several values to suppress:
NOT IN ('B', 'G', 'X')

If you just wanted to suppress the header name and keep the detail items in
the report, you could use a text box in the group header, and set its
Control Source to:
=IIf([Field1]='B', Null, [Field1])
Set its CanShink to Yes to squash up the space.

It is also possible to use the Format event of the Group Header to set
its
Visible property, or the report's runtime properties PrintSection and
MoveLayout. However, this is inferior to the techniques above as it
messes
up the page count, can yield nonsense like "Page 8 of 6", and can even yield
inconsistent results if you print only some pages of the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Alan Z. Scharf said:
Hi,

Is it possible to suppress printing of individual group header lines,
depending on a condition - say the value of the group header control or
the
value of another control in the group header section?

For example, I wouold like to suppress printing of Group Header B below if
value of the Group Header is B.

Group Header A
Detail 1
Detail 2
Group Header B <-- suppress printing of this group header and detail
lines
Detail 1
Detail 2
Group Header C
Detail 1
Detail 2

I know how to suppress the entire group section based on a condition, but
here I need to suppress only certain group header values.

Thanks.

Alan
 
A

Alan Z. Scharf

Allen,

Your suggestion about altering the query string made me realize that I could
just delete the rows I didn't want from my report table.

I had been overly focused on the report mechanism.

Thanks again.

Alan



Allen Browne said:
1. The Not 'B' goes into the Criteria row of the *query* that supplies
records to the report (i.e. the query named in the report's RecordSource
property.) Removing the records from the query is much simpler and more
efficient than letting them into the report and trying to clobber them
there.

So, for your particular case, you would want to enter this in the the
Criteria row in query design, under the field you are grouping on:
Is Null OR Not "Sharpe Ratio"

2. Likewise, you can enter the criteria under Years and SortOrder fields in
your query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Alan Z. Scharf said:
Allen,

Thanks very much for your reply.

1. Could you give a little more detail as to where exactly the 'Not B'
would
go. In the actual control on which the group breaks? Or another field?
Is
it a formula with equal sign?

An actual example would be where I want to suppress the group if the value
of the group header field = "Sharpe Ratio"

2. Another condition I also need to use to suppress a particular group
header is the following

Me.Years < 1 And Me.SortOrder > 3 Then
Suppress group header
End If

where Years and SortOrder are additonal controls in the group header
section.

The objective here is to suppress the group header if there is less than
one
year's worth of data.

Thanks again.

Alan



Allen Browne said:
If you want to suppress both the group header and the detail lines, the
simplest way will be to use a query as the RecordSource of the report. Under
the field that feeds you group header, enter criteria of:
NOT 'B'
or if there are several values to suppress:
NOT IN ('B', 'G', 'X')

If you just wanted to suppress the header name and keep the detail
items
in
the report, you could use a text box in the group header, and set its
Control Source to:
=IIf([Field1]='B', Null, [Field1])
Set its CanShink to Yes to squash up the space.

It is also possible to use the Format event of the Group Header to set
its
Visible property, or the report's runtime properties PrintSection and
MoveLayout. However, this is inferior to the techniques above as it
messes
up the page count, can yield nonsense like "Page 8 of 6", and can even yield
inconsistent results if you print only some pages of the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Hi,

Is it possible to suppress printing of individual group header lines,
depending on a condition - say the value of the group header control or
the
value of another control in the group header section?

For example, I wouold like to suppress printing of Group Header B
below
if
value of the Group Header is B.

Group Header A
Detail 1
Detail 2
Group Header B <-- suppress printing of this group header and detail
lines
Detail 1
Detail 2
Group Header C
Detail 1
Detail 2

I know how to suppress the entire group section based on a condition, but
here I need to suppress only certain group header values.

Thanks.

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top