Solved

Identify the number of report grouplevels??

Posted on 2002-04-28
9
151 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
ID: 6975853
iterate from 0 to (grouplevels.count-1)
0
 

Author Comment

by:onegui
ID: 6976267
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
ID: 6976928

For i = 0 To (Reports(0).GroupLevel.Count-1)  
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:onegui
ID: 6978233
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
 

Author Comment

by:onegui
ID: 6982993
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
ID: 6983102
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
ID: 6983128
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
ID: 6983148
it will do..thanks for your time mate

onegui
0
 
LVL 45

Expert Comment

by:aikimark
ID: 6983151
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using Access 8 83
Cannot Load VB6 on Windows 10. Installed OK but error on opening existing project. 7 115
VBA filters 2 70
Can we place a tooltip on the actual vb6 form 5 50
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

685 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