title: Identify Reports with Group-Level headers in MS Access 2007
body: <p>In MS Access 2007 I have an issue where different users want different color setttings on the  Report headers due to printer limitations.  Programatically I have established a means to change the colors of the Report and Page Header, which every Report contains; however, about half of the reports contain Group-level Headers.  My question is how can identify instances of Group-level Headers for reports within the .AllReports Collection?</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub ChangeHeaderColor(ByVal blnIsObjectLoaded As Boolean, _
                                ByVal intCounter As Integer, _
                                ByVal strObjectName As String, _
                                ByVal strObjectType As AcObjectType, _
                                ByVal lngHexColor As Long)
  
  On Error GoTo OpenAllReports_Error
  
  Dim rpt As Report
  
  If blnIsObjectLoaded = False Then
      DoCmd.OpenReport strObjectName, acDesign, , , acHidden
      If intCounter &lt; Reports.Count Then
          If IsNull(Reports.Item(intCounter).Section(acGroupLevel1Header)) Then
              Set rpt = Reports.Item(intCounter)
              rpt.Section(acGroupLevel1Header).BackColor = lngHexColor
          End If
      End If
  End If
  </code></pre>
  
  <p>...</p>
  
  <p>The issue is defining the correct If statement to ID only those Reports with a GroupLevel Header.  I am not aware of any method other than capturing the 2462 runtime error - "the Section number you enterred is invalid."</p>