Crystal Reports - top N at runtime

dingo1495

Member
Joined
Jun 20, 2005
Messages
5
Programming Experience
3-5
Hi,

I am trying the set the summary value in the report to be used to determine the topN records.
Eg
sum Sales$ sum GP$ GP%

How can i parse a value so the topN can be changed at runtime by the end user. So order by sum Sales or sum GP$

Cheers
Dan
 
Sorry.... must have been asleep when I was thinking about this one - incase you want to know you have to list the sort types in the TopN tool in crystal under the ALL option. Then tell the report at runtime which sort to apply to the data - '0' is the first sort option in crystal

crReport.DataDefinition.SortFields.Item(0).Field = setGroupOrder(crReport, 0)
crReport.DataDefinition.SortFields.Item(0).SortDirection = SortDirection.DescendingOrder

Private Function setGroupOrder(ByVal cr As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal field As Integer) As FieldDefinition
Dim FieldDef As FieldDefinition
FieldDef = cr.DataDefinition.SortFields(field).Field
Return FieldDef
End Function
 
Back
Top