Hiding group headers

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a report with grouping levels something like the
following:

Team 1
--------------------------------------------
Name 1 Amount 1/1 Amount 1/2
Name 2 Amount 2/1 Amount 2/2

I would like to make the group heading invisible (when
previewing and printing) in case Amount 1/1 or Amount 2/1
is empty (Null).

Is it possible?
Thank you in advance
 
One way would be to simply use Is Not Null as the criteria for both those
fields in the query that is Record Source, if you not only don't want to see
the group header but also don't want any detail for those groups.

If you do want the detail, you can put code in the Format or Print event to
check for Null and set the Visible property of pertinent section or
controls.

Larry Linson
Microsoft Access MVP
 
Dear Larry,
I am trying to put a code into the Format event to check
for Null and set the Visible property of the section, but
all in vain - the headear is still shown. I'm a beginner
in programming. Please, have a look at the code and point
out the mistake.

Private Sub Group2Header_Format(Cancel As Integer,_
FormatCount As Integer)
If Me.[Amount1] is Null Then
Group2Header.Visible = False
Else Group2Header.Visible = True
End If
End Sub
 
Mike said:
Dear Larry,
I am trying to put a code into the Format event to check
for Null and set the Visible property of the section, but
all in vain - the headear is still shown. I'm a beginner
in programming. Please, have a look at the code and point
out the mistake.

Private Sub Group2Header_Format(Cancel As Integer,_
FormatCount As Integer)
If Me.[Amount1] is Null Then
Group2Header.Visible = False
Else Group2Header.Visible = True
End If
End Sub

Instead of trying to hide the section, set the Cancel argument of the event
to true and the section will simply be skipped entirely by the report.

Private Sub Group2Header_Format(Cancel As Integer, FormatCount As Integer)
Cancel = IsNull(Me.[Amount1])
End Sub
 
Back
Top