"Dorian Chalom" wrote
I want to do this to determine if
a Group Level Exists. I was hoping
to create a function to go through all
the group levels in a given report and
return whether or not a GroupLevel
exists or not. If you have a better way
to determine if a group level exist for
any given report I would be most
interested.
Hmm. Better way than _what_?
I want to do this in report view.
I have a series of reports that are
simular in design and most all the
reports have the same Group Levels
but a couple do not and it is for those
few that do not that I want to detect
if the group level exists or not. So I
can avoid trying to work with the
Group Levels.
I hope you have a clearer understanding
and are able to help.
No, I really don't understand what you mean by "avoid trying to work with
the Group Levels" but perhaps that isn't important. The non-existent Group
Headers and Group Footers for non-existent Groups in a Report cannot execute
any code, in any case.
There is a GroupLevel property, which is an array, and it, in turn, has
properties. The following code will error out with an error 2464 when it
encounters the first non-existent GroupLevel, which I fielded in the Error
Process and simply displayed a MsgBox, but once you reach the Error Process
and test for Err.Number 2464, you can handle any way you wish.
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Proc
Dim lngL As Long
For lngL = 0 To 9
Debug.Print lngL, Me.GroupLevel(lngL).ControlSource
Next lngL
Exit_Proc:
Exit Sub
Err_Proc:
MsgBox "Error " & Err.Number & ": " & Err.Description _
& vbCrLf & "Failed at Level = " & lngL
Resume Exit_Proc
End Sub