Solved

Identify the number of report grouplevels??

Posted on 2002-04-28
9
154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 46

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 46

Expert Comment

by:aikimark
ID: 6976928

For i = 0 To (Reports(0).GroupLevel.Count-1)  
0
Industry Leaders: 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 46

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 46

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 9 hours left to enroll

636 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