This is going to be a horrible technical entry. I have been having a problem with Crystal Reports under VB.NET. I have not been able to SUM up fields. I have been able to get the MAXIMUM and MINIMUM of the field within a group, but not the SUM. Turns out that the MAXIMUM and MINIMUM are the top and bottom of the list if placed into alphabetical order.

Anyway, I have been using XML datasets in VB.NET to create custom data to report on. This makes the reports in crystal reports much easier since they do not need to include significant amounts of business logic that is best handled outside that application. Anyway to add the fields to the dataset I would use a line like the following one :-
dsnew.Tables(0).Columns.Add(“StopPlace”)
And this worked. And it worked really well. But there was one problem. From what I can work out this exported the data as a text field, and not as a number. So I needed to change that. Reading the manual (Yeah, I know that is dangerous, but it worked this time) I found out that I could say what the data was. That is with a line such as :-
dsnew.Tables(0).Columns.Add(“JourneyTime”, System.Type.GetType(“System.Double”))
This says that the data is not a string, but really a number. And since it is a number, Crystal Reports will do mathematical equations on it. Including SUM. In order to do a sum, all I needed to do was right click on the report and say ‘Include Subtotal’. And that was that. Things suddenly started working.

I do not know how much time I wasted on it 🙁 Anyway it is working now. I did find another way around this – I created a virtual field with the value of val({FIELD NAME}), but this got messy. Doing it properly is clean. I did learn some Crystal Reports out of this, but I could have used the time better in other ways.
=