cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting by FormulaField

0 Kudos

I've begun the task of bringing out CR to the 21st century. The templates were created more than 10 years ago, as well as the application written in Visual Basic that allows a user to pick different options before they click a button for generating a report.

So far the process hasn't been too bad but I've stumbled upon something that I can't figure out.

In VB, there's a line of code that sorts the report by a database table field:

Report.RecordSortFields.Add Report.Database.Tables(1).fields.GetItemByName("Name"), crAscendingOrder

I've successfully got that same logic working using the lines below

DatabaseFieldDefinition databaseFieldDefinition = Report.Database.Tables["Bureau"].Fields["Name"];

SortField sortField = Report.DataDefinition.SortFields[0];

sortField.Field = databaseFieldDefinition;

sortField.SortDirection = SortDirection.AscendingOrder;

The other type of sorting is what I'm struggling with.

The VB line of code is:
Report.RecordSortFields.Add Report.FormulaFields.GetItemByName("AssetName"), crAscendingOrder

As you can see, unlike the above example this is sorting by formula field. I can't seem to figure out how to write the code for this.

I know I can get the formula field using the below line but can't seem to make it work:

Report.DataDefinition.FormulaFields["AssetName"];

Any help would be appreciated

DellSC
Active Contributor
0 Kudos

Hi Joseph,

I updated your primary tag to "SAP Crystal Reports, version for Visual Studio" because you're asking about how to do something in code. The "SAP Crystal Reports" tag is for questions about designing reports.

-Dell Stinnett-Christy
Moderator

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Joseph,

Was that the RDC you used to use?

I don't see an obvious way but asking others if they know of any way to sort the list.

In CR Designer you can right click and sort them but the same report returns them in order you added them...

Don

Answers (0)