Skip to Content
0
Former Member
Apr 29, 2016 at 05:34 PM

Adding sortfields in crystal reports 2013

293 Views

Hi everybody.

There is a way to add a sortfield at runtime without loosing the sortfields created at design time?

I have a report with a gruop by invoice_id. This sorts a report invoice_id. In the detail section I have the articles. But I want to let the user to choose the sort oder: by article code or by article description. Using this code I can change the sortfields, but it seems to remove the first sort field, wich need to be the invoice_id

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Private f_rd_Reporte As ReportDocument

Dim l_fd_SortField As FieldDefinition 'miembro de CrystalDecisions.CrystalReports.Engine

l_fd_SortField = f_rd_Reporte.Database.Tables("invoices").Fields("article_cod")

f_rd_Reporte.DataDefinition.SortFields(0).Field = l_fd_SortField

f_rd_Reporte.DataDefinition.SortFields(0).SortDirection = SortDirection.AscendingOrder

Using index of 1 instead of 0 gives me an error of "out of index" (DISP_E_BADINDEX).

Need something like an Add method:

f_rd_Reporte.DataDefinition.SortFields.Add(l_fd_SortField, SortDirection.AscendingOrder)




Regards.

Damian.