Dynamic Group Headers

M

Microsoft

Access 2007

I have a report

SectionGrp
SubSectionGrp
Detail

I want 'continued' to be added to SectionGrp when it is repeated on a new
page.
I have:

=[SectionGrp] & IIf([txtHdrCount]>1," continued","")

this works fine UNLESS I set the PrintSection to FALSE for the
SubSectionGrp.
I do this when there isn't any subsection analysis set up.

How can I get around this problem?
Thanks
Alison
 
M

Marshall Barton

Microsoft said:
Access 2007

I have a report

SectionGrp
SubSectionGrp
Detail

I want 'continued' to be added to SectionGrp when it is repeated on a new
page.
I have:

=[SectionGrp] & IIf([txtHdrCount]>1," continued","")

this works fine UNLESS I set the PrintSection to FALSE for the
SubSectionGrp.
I do this when there isn't any subsection analysis set up.

Try either cancelling the Format event of the SubSectionGrp
group header or making header invisible instead of using
PrintSection.
 
M

Microsoft

Thanks for your help
I tried making the section invisible but this still didn't work.....
What do you mean by cancelling the Format Event?
Marshall Barton said:
Microsoft said:
Access 2007

I have a report

SectionGrp
SubSectionGrp
Detail

I want 'continued' to be added to SectionGrp when it is repeated on a new
page.
I have:

=[SectionGrp] & IIf([txtHdrCount]>1," continued","")

this works fine UNLESS I set the PrintSection to FALSE for the
SubSectionGrp.
I do this when there isn't any subsection analysis set up.

Try either cancelling the Format event of the SubSectionGrp
group header or making header invisible instead of using
PrintSection.
 
M

Marshall Barton

Microsoft said:
I tried making the section invisible but this still didn't work.....
What do you mean by cancelling the Format Event?


The Format and Print event procedures have a Cancel
argument. If you set it to True, the section will not
appear.

Id making the section invisible didn't work, then I doubt
that using canel will make a difference.

Maybe it would clarify your situation if you explained what
is happening when "it doesn't work".
 
M

Microsoft

By 'doesn't work' I mean that it fails to add the continued to the Section
Header when it goes over the page

SectionGrp
SubSectionGrp
Detail

I want 'continued' to be added to SectionGrp when it is repeated on a new
page.

I have in the SectionGrp Header:

=[SectionGrp] & IIf([txtHdrCount]>1," continued","") ----- txtHdrCount is
in the SubSectionGrp Header

If I don't print or make invisible the SubSectionGrp because there is no
info for it, it fails to add 'continued' in the SectionGrp Header when it
goes to the next page.

Thanks for your help so far......
Alison
 
M

Marshall Barton

I'm confused. If there are no records for a subsection, how
do you get a subsectiongrp to hide??

I think I need more details about the groups and the
txtHdrCount text box.

Here's a thought. If txtHdrCount is a details section text
box with -1 and RunningSum. Then each new subsection will
start over with txtHdrCount = 1 so the continued will not
appear when a subsection starts on a new page. To get a
higher level to display "continued" across subgroups, you
need multiple counters or a counter that does not start over
(messy and not worth it).
--
Marsh
MVP [MS Access]

By 'doesn't work' I mean that it fails to add the continued to the Section
Header when it goes over the page

SectionGrp
SubSectionGrp
Detail

I want 'continued' to be added to SectionGrp when it is repeated on a new
page.

I have in the SectionGrp Header:

=[SectionGrp] & IIf([txtHdrCount]>1," continued","") ----- txtHdrCount is
in the SubSectionGrp Header

If I don't print or make invisible the SubSectionGrp because there is no
info for it, it fails to add 'continued' in the SectionGrp Header when it
goes to the next page.

The Format and Print event procedures have a Cancel
argument. If you set it to True, the section will not
appear.

Id making the section invisible didn't work, then I doubt
that using canel will make a difference.

Maybe it would clarify your situation if you explained what
is happening when "it doesn't work".
 
M

Microsoft

OK here is what I have - any clearer?
Thanks for your help

In the SectionGrp Header is the following:
=[SectionGrp] & IIf([txtHdrCount]>1," continued","")

The txtHdrCount is in the SubSectionGrp Header

In the SubSectionGrp Header is the following:
=" - " & [SectionGrp2] & IIf([txtLineItem]>1," continued","")

txtLineItem is a counter in the Detail Section

In the OnFormat Event of SubSectionGrp Header is the following code:

Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)

Me.txtSectionGrp2.Visible = True

If txtSectionGrp2 = " - " Then
Me.PrintSection = False
Me.MoveLayout = False
ElseIf txtSectionGrp2 = " - continued" Then
Me.PrintSection = False
Me.MoveLayout = False
ElseIf txtSectionGrp2 = "" Then
Me.PrintSection = False
Me.MoveLayout = False
End If
End Sub


Marshall Barton said:
I'm confused. If there are no records for a subsection, how
do you get a subsectiongrp to hide??

I think I need more details about the groups and the
txtHdrCount text box.

Here's a thought. If txtHdrCount is a details section text
box with -1 and RunningSum. Then each new subsection will
start over with txtHdrCount = 1 so the continued will not
appear when a subsection starts on a new page. To get a
higher level to display "continued" across subgroups, you
need multiple counters or a counter that does not start over
(messy and not worth it).
--
Marsh
MVP [MS Access]

By 'doesn't work' I mean that it fails to add the continued to the Section
Header when it goes over the page

SectionGrp
SubSectionGrp
Detail

I want 'continued' to be added to SectionGrp when it is repeated on a new
page.

I have in the SectionGrp Header:

=[SectionGrp] & IIf([txtHdrCount]>1," continued","") ----- txtHdrCount
is
in the SubSectionGrp Header

If I don't print or make invisible the SubSectionGrp because there is no
info for it, it fails to add 'continued' in the SectionGrp Header when it
goes to the next page.

Microsoft wrote:
I tried making the section invisible but this still didn't work.....
What do you mean by cancelling the Format Event?


The Format and Print event procedures have a Cancel
argument. If you set it to True, the section will not
appear.

Id making the section invisible didn't work, then I doubt
that using canel will make a difference.

Maybe it would clarify your situation if you explained what
is happening when "it doesn't work".
 
M

Marshall Barton

Microsoft said:
OK here is what I have - any clearer?
Thanks for your help

In the SectionGrp Header is the following:
=[SectionGrp] & IIf([txtHdrCount]>1," continued","")

The txtHdrCount is in the SubSectionGrp Header

In the SubSectionGrp Header is the following:
=" - " & [SectionGrp2] & IIf([txtLineItem]>1," continued","")

txtLineItem is a counter in the Detail Section

In the OnFormat Event of SubSectionGrp Header is the following code:

Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)

Me.txtSectionGrp2.Visible = True

If txtSectionGrp2 = " - " Then
Me.PrintSection = False
Me.MoveLayout = False
ElseIf txtSectionGrp2 = " - continued" Then
Me.PrintSection = False
Me.MoveLayout = False
ElseIf txtSectionGrp2 = "" Then
Me.PrintSection = False
Me.MoveLayout = False
End If
End Sub


I will assume that both txtHdrCount and txtLineItem are text
boxes with expression =1 and RunningSum Over Group.

As I suspected, the expression in the section group header
is inadequate. It should be:
=SectionGrp & IIf(txtHdrCount>1 OR txtLineItem>1,"
continued","")

Your code for the subsection header is overly complex:

The second ElseIf can never happen.

The If and first ElseIf can only happen if SectionGrp2 is
Null or a zero length string. If this ever happens, it
seems like there might be a flaw in your data. What does it
mean to have an unnamed subsection with empty details?
Depending on the report's record source, it could mean that
you have records with no data, which is a usually a symptom
of something wrong in a data entry form.

If you really have a reason for that kind of record in the
report's record source table/query, then the code could
simply be:
Cancel = (Nz(SectionGrp2, "") = "")
 
M

Microsoft

Thanks works a treat!
Marshall Barton said:
Microsoft said:
OK here is what I have - any clearer?
Thanks for your help

In the SectionGrp Header is the following:
=[SectionGrp] & IIf([txtHdrCount]>1," continued","")

The txtHdrCount is in the SubSectionGrp Header

In the SubSectionGrp Header is the following:
=" - " & [SectionGrp2] & IIf([txtLineItem]>1," continued","")

txtLineItem is a counter in the Detail Section

In the OnFormat Event of SubSectionGrp Header is the following code:

Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)

Me.txtSectionGrp2.Visible = True

If txtSectionGrp2 = " - " Then
Me.PrintSection = False
Me.MoveLayout = False
ElseIf txtSectionGrp2 = " - continued" Then
Me.PrintSection = False
Me.MoveLayout = False
ElseIf txtSectionGrp2 = "" Then
Me.PrintSection = False
Me.MoveLayout = False
End If
End Sub


I will assume that both txtHdrCount and txtLineItem are text
boxes with expression =1 and RunningSum Over Group.

As I suspected, the expression in the section group header
is inadequate. It should be:
=SectionGrp & IIf(txtHdrCount>1 OR txtLineItem>1,"
continued","")

Your code for the subsection header is overly complex:

The second ElseIf can never happen.

The If and first ElseIf can only happen if SectionGrp2 is
Null or a zero length string. If this ever happens, it
seems like there might be a flaw in your data. What does it
mean to have an unnamed subsection with empty details?
Depending on the report's record source, it could mean that
you have records with no data, which is a usually a symptom
of something wrong in a data entry form.

If you really have a reason for that kind of record in the
report's record source table/query, then the code could
simply be:
Cancel = (Nz(SectionGrp2, "") = "")
 

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