-
Mar 8th, 2004, 06:33 PM
#1
Thread Starter
Fanatic Member
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.
-
Mar 8th, 2004, 07:23 PM
#2
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:
Dim objSubReport As CRAXDRT.Report
Set objSubReport = vrptObj.OpenSubReport("SomeName")
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:
Dim objApp As CRAXDRT.Application
Dim objRep As CRAXDRT.Report
Dim objSubReport As CRAXDRT.Report
Dim objSections As CRAXDRT.Sections
Dim objSection As CRAXDRT.Section
Dim objReportObjects As CRAXDRT.ReportObjects
Dim objSubReportObject As CRAXDRT.SubreportObject
Dim lngIdx As Long
Set objApp = New CRAXDRT.Application
Set objRep = objApp.OpenReport(strReportName)
Set objSections = objRep.Sections
For Each objSection In objSections
Set objReportObjects = objSection.ReportObjects
If objReportObjects.Count > 0 Then
For lngIdx = 1 To objReportObjects.Count
'make sure the report object is a subreport.
If objReportObjects(lngIdx).Kind = crSubreportObject Then
'open the subreport
Set objSubReportObject = objReportObjects(lngIdx)
Set objSubReport = objSubReportObject.OpenSubreport
If objSubReport.GroupSortFields.Count > 0 Then
objSubReport.GroupSortFields(1).SortDirection = lngSortDirection
End If
End If
Next
End If
Next
-
Mar 8th, 2004, 07:58 PM
#3
Thread Starter
Fanatic Member
-
Mar 9th, 2004, 12:06 AM
#4
Thread Starter
Fanatic Member
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?
-
Mar 9th, 2004, 01:05 AM
#5
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|