Link to home
Start Free TrialLog in
Avatar of qford
qford

asked on

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.
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

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
correction...
Please igoner first "In the on formate of the Group Header in question have:"

Avatar of qford
qford

ASKER

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?

SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If a solutin works, it is smart. Thanks for sharing.

Mike