VB.NET Crystal Reports Summary Fields

All the programming examples for Crystal Reports in these tutorials are derived from the underlying database, crystaldb. Before commencing this tutorial, it is recommended that you familiarize yourself with the structure of the database. To access the database structure, kindly click on the provided link: Click here to view the Database Structure .

In this tutorial, our focus lies in calculating the summation of the field value for "Total." This tutorial serves as a continuation of the preceding lesson on Crystal Report Formula Field. Hence, it is advisable to review the aforementioned tutorial, Crystal Report Formula Field before proceeding with this one.

Within this tutorial, our objective is to obtain the grand total of the "Total" field. It is noteworthy that the "Total" field is a formula field representing the result of multiplying the quantity by the price.

In the Crystal Reports designer view right click on the Report Footer , just below the Total field and select Insert -> Summary.

vb.net_crystal_report_summary_field_1.GIF

Then you will get a screen , select the Total from the combo box and Sum from next Combo Box , and summary location Grand Total (Report Footer) . Click Ok button.

vb.net_crystal_report_summary_field_2.GIF

Now you can see @Total is just below the Total field in the report Footer.

vb.net_crystal_report_summary_field_3.GIF

Now the designing part is over . Select the default form (Form1.vb) you created in VB.NET and drag a button and CrystalReportViewer control to your form.

Select Form's source code view and import the following :

Imports CrystalDecisions.CrystalReports.Engine

Put the following source code in the button click event

Full Source VB.NET
Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim cryRpt As New ReportDocument cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt") CrystalReportViewer1.ReportSource = cryRpt CrystalReportViewer1.Refresh() End Sub End Class
NOTES:

cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")

The Crystal Report is in your project location, there you can see CrystalReport1.rpt . So give the full path name of report here.

When you run this program you will get the following screen.

vb.net_crystal_report_summary_field_4.GIF