Solved Need to hide the Report header of subreports in a report (1 Viewer)

autumnnew

Member
Local time
Today, 10:08
Joined
Feb 4, 2013
Messages
44
How can I hide the report header of subreports in a report?

I have a report with 2 subreports and would like to hide the report header for each of the subreports. The subreports are also stand alone reports, so their report headers have a Close and a Print button, which are displayed for screen only.

This report is for the event that a user needs both reports, so the close/print buttons look awkward in this report.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:08
Joined
May 21, 2018
Messages
8,529
Check if a report is open as subreport
Code:
Public Function isSubReport(Rpt As Access.Report) As Boolean
  On Error Resume Next
  isSubReport = Not (Rpt.Parent Is Nothing)
End Function

In the subreport / report
Code:
Private Sub Report_Open(Cancel As Integer)
  If isSubReport(Me) Then
    'Me.PageHeader.Visible = False
    Me.ReportHeader.Visible = False
  End If
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:08
Joined
May 7, 2009
Messages
19,245
The subreports are also stand alone reports, so their report headers have a Close and a Print button, which are displayed for screen only.
the simplest i can think it copy the 2 sub-report and on the 2 copies (also rename the copy), you remove the page header
and use this as your sub-reports.

no code required.

if you think creating a report will greatly increase the size of your db or slows it down. No.
i have worked with a db before with 533 report!
reps.png
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:08
Joined
May 21, 2018
Messages
8,529
@autumnnew,
Duplicating reports or forms may be easy and not resource intensive, but this can lead to a pain in configuration management trying to synchronize changes on two identical reports/forms. So weigh the pros and cons. I personally do the opposite and try to limit the number of forms/reports if I can configure them in code.
 

autumnnew

Member
Local time
Today, 10:08
Joined
Feb 4, 2013
Messages
44
Check if a report is open as subreport
Code:
Public Function isSubReport(Rpt As Access.Report) As Boolean
  On Error Resume Next
  isSubReport = Not (Rpt.Parent Is Nothing)
End Function

In the subreport / report
Code:
Private Sub Report_Open(Cancel As Integer)
  If isSubReport(Me) Then
    'Me.PageHeader.Visible = False
    Me.ReportHeader.Visible = False
  End If
End Sub
Thank you, that worked perfectly! You have been SO helpful!

Duplicating reports or forms may be easy and not resource intensive
I've been trying to reduce and limit as much redundancy as I can. If I were still intimidated by code, I would've duplicated the reports like he suggested.

if you think creating a report will greatly increase the size of your db or slows it down. No.
i have worked with a db before with 533 report!
Yikes, 533 reports! I hadn't thought of duplicating the reports. Before I ventured into code, that would be the kind of workaround I would usually do.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:08
Joined
May 7, 2009
Messages
19,245
again this is manageable.
you don't treat the "copy" as same object.
or it is a redundant.
you treat it to have it's own identity, a separate report.

image you need to modify the "orig" and retain the format of the "copy".
you then are bound to create more code.

this is the same as having 2 table with exact structure, but each
has it's own purpose.
 

autumnnew

Member
Local time
Today, 10:08
Joined
Feb 4, 2013
Messages
44
you treat it to have it's own identity, a separate report.
I understood, and that's how I would've done it. It works either way, but the less objects in the Nav pane for me, the better.
 

Users who are viewing this thread

Top Bottom