Results 1 to 5 of 5

Thread: crystal, [resolved].

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    crystal, [resolved].

    Normally to set the stort direction on a group you would do something like this:
    Code:
    vrptObj.GroupSortFields(1).SortDirection = crDescendingOrder
    But how could I set the sort direction on multiple sub reports if each sub report has one group, at run-time?
    Last edited by nkad; Mar 9th, 2004 at 04:58 AM.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    If you know the names of the subreport and can are sure they contain a group sorting - open subreport directly and set the property.

    VB Code:
    1. Dim objSubReport As CRAXDRT.Report
    2. Set objSubReport = vrptObj.OpenSubReport("SomeName")
    3. objSubReport.GroupSortFields(1).SortDirection = crDescendingOrder

    Try the following if you are looking for a generic procedure. Basically, go through the object hierarchy to open the sub reports and set the sorting.

    VB Code:
    1. Dim objApp As CRAXDRT.Application
    2.     Dim objRep As CRAXDRT.Report
    3.     Dim objSubReport As CRAXDRT.Report
    4.    
    5.     Dim objSections  As CRAXDRT.Sections
    6.     Dim objSection As CRAXDRT.Section
    7.     Dim objReportObjects As CRAXDRT.ReportObjects
    8.     Dim objSubReportObject As CRAXDRT.SubreportObject
    9.    
    10.     Dim lngIdx As Long
    11.    
    12.     Set objApp = New CRAXDRT.Application
    13.  
    14.     Set objRep = objApp.OpenReport(strReportName)
    15.    
    16.     Set objSections = objRep.Sections
    17.  
    18.     For Each objSection In objSections
    19.        
    20.         Set objReportObjects = objSection.ReportObjects
    21.        
    22.         If objReportObjects.Count > 0 Then
    23.  
    24.             For lngIdx = 1 To objReportObjects.Count
    25.                 'make sure the report object is a subreport.
    26.                 If objReportObjects(lngIdx).Kind = crSubreportObject Then
    27.  
    28.                     'open the subreport
    29.                     Set objSubReportObject = objReportObjects(lngIdx)
    30.                     Set objSubReport = objSubReportObject.OpenSubreport
    31.                     If objSubReport.GroupSortFields.Count > 0 Then
    32.                          objSubReport.GroupSortFields(1).SortDirection = lngSortDirection
    33.                    End If
    34.                 End If
    35.             Next
    36.         End If
    37.     Next

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    Cool, thanks...

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    brucevde,

    I don't get any errors. The code does find the subreports in each section of the report but for some reason it is not setting the sort direction.

    It seems that
    Code:
    objSubReport.GroupSortFields.Count always = 0
    To me that doesn't make since considering that the group in the subreport does infact exist, so why would it be zero?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    I figured it out, never mind...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width