Access 2007 – Group Header Duplicate on Unbound Report

I am creating a report with two subreports. The main report will be unbound and will only serve as a container for two unrelated reports. Each subreport can be multiple pages and needs to have the page header repeat for each page. Putting the info in the Page Header works great as a standalone report but fails as a subreport. I created a Group based on the expression “=1” and this achieves my goal of repeating the header info for each page.

My problem is that when I set “Repeat Section” to “Yes” on the Group, it duplicates the title information on the first page. Each subsequent page has it only one time at the top of the page. Actually, one report works properly and the other has this duplication. It seems that if the report is bound to a record source then it works properly but an unbound report has the duplication. You can replicate the problem with a new blank report that is unbound, creating a group and setting the group “Repeat Section” to “Yes”. Such as:
Create a blank report.
Add a Group.
      Expression: =1
      Title: Hello
Change the “Repeat Section” of the Group Header to “Yes”
When you Print or Print Preview the report, it displays the group title twice. Such as:
Hello
Hello

Why is the Group Header duplicating on the first page? Is there a way to fix it besides setting a Record Source on the report?

Thanks for your help.
qfordAsked:
Who is Participating?
 
qfordAuthor Commented:
Thank you for your input. I have thought a lot about your suggestion and have done some experiments but am not comfortable that it will be consistent enough not to cause us problems down the road.

For a solution, I bound the subreport to a table and filtered it to one record. This way my header is printed one time on each page and my pages of text are printed one time. Stupid but it works.

I am going to split the points because your solution has merit even though I chose not to use it. Thanks again.
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
I think we can force the header to be invisible under certain condition, like

if we include a public variable in the report module like:

Public intCount as integer
============
In the on open event of report have

In the on formate of the Group Header in question have:

intCount  = 0 ' although this may be not necessary


In the on format of the Group Header in question have:

intCount  =  intCount  +1
txtCount  = intCount       '<-- add txtCount temporarily in the group saction

============

Then instead of:

Hello
Hello

You will get

Hello     1
Hello      2

I would hope. If this is how it turns out to be, then change the code to:

intCount  =  intCount  +1
If intCount =1 then
      GroupHeader.Visible=False
Else

      GroupHeader.Visible=True

End IF


Note:  GroupHeader may be named differebtly. Youn need to come up with it yourself.

Mike
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
correction...
Please igoner first "In the on formate of the Group Header in question have:"

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
qfordAuthor Commented:
Thank you for this idea. intCount will start out as ‘5’ if the report is run directly and as ‘14’ if run as a subreport. I placed a msgBox in the ‘on format’ of the group header to see how intCount was incrementing which showed that it is properly starting at zero. Based on the reading I have done, it seems to me that the ‘on format’ event gets called too inconsistently to reliably accomplish what we are trying to accomplish. It is a clever idea but does not appear to accomplish our goal (reliably). Thanks again for your help.

Any other ideas on how to fix this or background information that explains why this is a problem in the first place?

0
 
Mike EghtebasDatabase and Application DeveloperCommented:
So, if you can make it run consistently , then you agree that it will work. Then make it run consistently.

- To do this, don't use message box, use txtCount as it was sugested.
- Also add the following code to report header on format (meaning for now make report header available if it is not in use). and add txtReportHeaderCount to it with the following code in its on format event:

iCount = 0
me!txtReportHeaderCount =iCount

This way, report header has to show zero (and here my focus is running it as subreport we will deal with the other option later).

A. Say you get 1 for the section you want to hide, use:

If intCount =1 then
     <GroupHeader you need to determine what it is>.Visible=False
Else
     GroupHeader.Visible=True
End IF
===================
B. Say you get 1 but sometimes 14, then use:

If intCount =1 and [Page]=1 then
     If intCount =14 and [Page]=1 then
          <GroupHeader you need to determine what it is>.Visible=False
     End If
Else
     GroupHeader.Visible=True
End IF


Mike
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
If a solutin works, it is smart. Thanks for sharing.

Mike
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.