• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • Last Modified:

Identify the number of report grouplevels??

Hi experts

i am looping around report group levels..
Problem...i dont know how many group levels a report may have, so i have to loop until the end..

once i get to the end of the group levels the program crashes because the object has no data..

i was advised to use the syntax
'If Not (Reports(0).GroupLevel(i) Is Nothing)

but his does not work, any ideas ??

below is an example of the code...
 'Identifies the sort order for each field
       'For i = 0 To 9
   
        'If Not (Reports(0).GroupLevel(i) Is Nothing) Then  'not work!!!
            If (Reports(0).GroupLevel(i).SortOrder) = False Then
                  MsgBox ("The Field " + Str(i) + " is in Descending Order")
            Else
                 MsgBox ("The Field " + Str(i) + " is in Ascending Order")
            End If
        'End If
        'Next i
0
onegui
Asked:
onegui
  • 5
  • 4
1 Solution
 
aikimarkCommented:
iterate from 0 to (grouplevels.count-1)
0
 
oneguiAuthor Commented:
Hello...

when i use your syntax above...

its crashes with the error message pertaining to grouplevels.

    "variable not defined"

ideas ??
0
 
aikimarkCommented:

For i = 0 To (Reports(0).GroupLevel.Count-1)  
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
oneguiAuthor Commented:
HI aikimark..

I think you must be guessing?

Grouplevel does not have a property count.
Therefore your code does not work.

Do you have any ideas ??
0
 
oneguiAuthor Commented:
HI experts..

does anyone have any ideas, or should i just delete the question??
0
 
aikimarkCommented:
I certainly was "shooting from the hip", because I truly thought that GroupLevel was a collection.  I appologize for my insufficiently researched answer.

1. You must attempt to iterate through all ten (possible) GroupLevels.
2. You must trap any raised errors resulting from an attempt to access an undefined GroupLevel.

Example:
On Error GoTo LeaveGroupProcessing
For i=0 to 9

    If (Reports(0).GroupLevel(i).SortOrder) = False Then
       MsgBox ("The Field " + Str(i) + " is in Descending Order")
    Else
       MsgBox ("The Field " + Str(i) + " is in Ascending Order")
    End If

Next i

Exit Sub

LeaveGroupProcessing:
   Exit Sub
0
 
oneguiAuthor Commented:
hi A
really?

i already thought i this, but thought this was a ugly piece of validation.

well..there must be another way
0
 
oneguiAuthor Commented:
it will do..thanks for your time mate

onegui
0
 
aikimarkCommented:
Realize that error-trapping changes with VB.Net (Try...Except...Finally)

=================================================
Try:
Dim strName as String
On Error Resume Next
For i=0 to 9
   strName = Reports(0).GroupLevel(i).name
   If Err = 0 Then
   Else
       Exit For
   End If
   If (Reports(0).GroupLevel(i).SortOrder) = False Then
      MsgBox ("The Field " + Str(i) + " is in Descending Order")
   Else
      MsgBox ("The Field " + Str(i) + " is in Ascending Order")
   End If

Next i
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now