on 04-29-2016 6:34 PM
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.
Instead of doing this in your application, try using a parameter in the report. Here's what you can do:
1. Create a parameter, which I will call {?SortOrder} which has the values "Code" and "Description".
2. Create a formula that will provide the values for the sort. It might look like this (assuming that both fields are string fields!):
{@SortOrder}
If {?SortOrder} = 'Code' then {invoices.article_cod} else {invoices.article_descrip}
3. Sort the report on this formula.
Your application would then just have to supply the value for this parameter base on what the user selects in the application.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No hablo ingles pero este problema lo resolvi con solo crear un indice en el reporte, en mi caso, yo debia permitir al usuario generar el crystalreport con tres forma de ordenamiento:
1. por recnum (orden de captura)
2. por descripcion del producto
3. por ubicacion del producto en bodega
el problema radica en que hay que ponerle por defecto, unos de esos tes campos al ordenar el reporte, al momento de diseñar el mismo. Esto deberia resolver tu problema.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.