Solved

Identify the number of report grouplevels??

Posted on 2002-04-28
9
146 Views
Last Modified: 2010-05-18
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
Comment
Question by:onegui
  • 5
  • 4
9 Comments
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
iterate from 0 to (grouplevels.count-1)
0
 

Author Comment

by:onegui
Comment Utility
Hello...

when i use your syntax above...

its crashes with the error message pertaining to grouplevels.

    "variable not defined"

ideas ??
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility

For i = 0 To (Reports(0).GroupLevel.Count-1)  
0
 

Author Comment

by:onegui
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:onegui
Comment Utility
HI experts..

does anyone have any ideas, or should i just delete the question??
0
 
LVL 45

Accepted Solution

by:
aikimark earned 100 total points
Comment Utility
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
 

Author Comment

by:onegui
Comment Utility
hi A
really?

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

well..there must be another way
0
 

Author Comment

by:onegui
Comment Utility
it will do..thanks for your time mate

onegui
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now