Solved

Identify the number of report grouplevels??

Posted on 2002-04-28
9
152 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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