Set Group Header Height Based on Criteria

  • Thread starter Thread starter mj
  • Start date Start date
M

mj

Hi. I have a group header that is a Rep and another group
header this is a RepSub as shown below.

Territory Rep RepSub
Atlantic Joe Brian
Atlantic Joe Jon
Atlantic Joe Sheila
Central Rich N/A
Northern Wendy N/A

I'm trying to make my group header programatically
collapse to a height of zero when the RepSub value
is "N/A" and not collapse when there is any other value
for RepSub. Any suggestions would be great. Thanks!!
 
on the OnFormat event of the Header check the criteria and
set the Heigth accordingly. Example

if me.field = "N/A" then
me.GroupHeader2.height = 0
else
me.GroupHeader2.height = 200
end if

The height value is in pixels and you can adjust it to
what you need.
 
on the OnFormat event of the Header check the criteria and
set the Heigth accordingly. Example

if me.field = "N/A" then
me.GroupHeader2.height = 0
else
me.GroupHeader2.height = 200
end if

The height value is in pixels and you can adjust it to
what you need.
 
Thanks for the suggestion. Looks like that could work. I
tried it but to no avail...What do you think? Am I missing
something?

Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)
If Me.IMRRepSub = "N/A" Then
Me.GroupHeader0.Height = 0
Else
Me.GroupHeader0.Height = 200
End If
End Sub
 
The Section height prop is not expressed in Pixels. The standard
TWIPS(1440/inch) is used everywhere within Access Form/Report design.

An alternative solution is to set the Visible prop for each control in
the section to false if the condition you wish to evaluate is TRUE. Make
sure the Can Shrink prop for the section is set to true.
 
mj said:
Hi. I have a group header that is a Rep and another group
header this is a RepSub as shown below.

Territory Rep RepSub
Atlantic Joe Brian
Atlantic Joe Jon
Atlantic Joe Sheila
Central Rich N/A
Northern Wendy N/A

I'm trying to make my group header programatically
collapse to a height of zero when the RepSub value
is "N/A" and not collapse when there is any other value
for RepSub. Any suggestions would be great. Thanks!!


It would be a lot easier to just sect the section's Visible
property to True or False as needed. Use the section's
Format event procedure:

Me.Section(7?).Visible = (Me.RepSub <> "N/A")

Alternatively, you can cancel the section's formatting.

Cancel = (Me.RepSub = "N/A")
 
The problem with setting the fields visible property to
false is that it still takes up space, awkward space, on
the report, but that's a good suggestion nonetheless.
Thanks.
 
mj said:
The problem with setting the fields visible property to
false is that it still takes up space, awkward space, on
the report, but that's a good suggestion nonetheless.


I think you misunderstood.

I suggested that you set the section invisible, not the
controls in the section.

Did you try my other suggestion of canceling the section's
Format event?
--
Marsh
MVP [MS Access]



 
Marsh, Thanks. I tried your suggestions as indicated below
but the GroupHeader is still showing up where IMRRepSub
= "N/A".

1.
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)

If Me.IMRRepSub = "N/A" Then
Me.GroupHeader0.Height = 0
Else
Me.GroupHeader0.Height = 200
End If

End Sub

2.
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)

If Me.IMRRepSub = "N/A" Then
Me.GroupHeader0.Visible = 0
Else
Me.GroupHeader0.Visible = 1
End If

End Sub

3.
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)

Cancel = (Me.GroupHeader0 = "N/A")

End Sub
-----Original Message-----
mj said:
The problem with setting the fields visible property to
false is that it still takes up space, awkward space, on
the report, but that's a good suggestion nonetheless.


I think you misunderstood.

I suggested that you set the section invisible, not the
controls in the section.

Did you try my other suggestion of canceling the section's
Format event?
--
Marsh
MVP [MS Access]




.
 
mj said:
Marsh, Thanks. I tried your suggestions as indicated below
but the GroupHeader is still showing up where IMRRepSub
= "N/A".

1.
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)

If Me.IMRRepSub = "N/A" Then
Me.GroupHeader0.Height = 0
Else
Me.GroupHeader0.Height = 200
End If

End Sub

2.
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)

If Me.IMRRepSub = "N/A" Then
Me.GroupHeader0.Visible = 0
Else
Me.GroupHeader0.Visible = 1
End If

End Sub

3.
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)

Cancel = (Me.GroupHeader0 = "N/A")

End Sub


Your first attempt can not succeed. The height of a section
can not be reduced to lees than the space required by its
controls.

The second and third ones should work, unless your group is
not grouping on the RepSub field, the RepSub contains
something other than "N/A" (without the quotes) or something
else about you report that I don't know about.

Even if the code was in the wrong header's Format event,
GroupHeader0 shoud disappear some of the time.

I guess I need more precise details about the grouping
levels and fields, what's int the detail section and the
exact value in the RepSub field (regardless of what's being
displayed in the RepSub control in the report).
 
Back
Top