VB.NET Crystal Reports Formula Fields
All Crystal Reports programming samples in this tutorials is based on the following database (crystaldb) . Please take a look at the database structure before you start this tutorial - Click here to see Database Structure .
In this tutorial we are adding a Formula Field in existing Crystal Reports .
SITUATIONS :
If you possess a Crystal Reports document containing quantity and price information, it is necessary to include an additional field in the report to calculate the total value derived from multiplying the quantity by the price. To accomplish this task, the Formula Field feature within Crystal Reports must be utilized.
In the forthcoming tutorial, we shall illustrate the display of all orders, encompassing quantity and price details alongside the corresponding total for each row. Each row will exhibit the cumulative sum of the quantity and price values. Before commencing this tutorial, it is advised to generate a fresh Crystal Reports document comprising the following fields: CustomerName, Order Date, Product Name, and Product Price. If you are unfamiliar with the report creation process, kindly refer to the preceding tutorial, Crystal Report from multiple tables where we elucidate the selection of four fields. However, for our present purposes, an additional field, namely "Prodcut->Price . is indispensable.
After you create the Crystal Reports you screen is look like the following picture :
Next is to create the a Formula Field for showing the total of Qty and Price .
Right Click Formula Field in the Field Explorer and click New. Then you will get an Input Message Box , type Total in textbox and click Use Editor.
Now you can see Formula Editor screen . Now you can enter which formula you want . Here we want the result of Qty X Price . For that we select OrderDetails.Qty , the multiplication operator and Product.Price . Double click each field for selection.
Now you can see Total Under the Formula Field . Drag the field in to the Crystal Reports where ever you want.
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 :
Put the following source code in the button click event
Full Source VB.NETcryRpt.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.
- Sample Database and tables for Crystal Reports tutorials
- Step by Step help for creating a simple Crystal Reports in VB.NET
- VB.NET Crystal Reports from multiple tables
- VB.NET Crystal Reports String parameter
- VB.NET Crystal Reports Integer parameter
- VB.NET Crystal Reports Date parameter
- VB.NET Crystal Report Load Dynamically
- VB.NET Crystal Reports Summary Fields
- VB.NET Crystal Reports Export to PDF
- VB.NET Crystal Reports Export to Excel
- Email a Crystal Reports from VB.NET
- Crystal Reports Without Database
- Crystal Report from SQL Query String
- Dynamic Crystal Reports from SQL Query String
- Crystal Reports from XML File
- Create a Subreport in Crystal Reports
- Create a Subreport in Crystal Reports with Link
- How to deploy Crystal Reports on Clinet Machine
- How to create Crystal Reports installer using Merge Modules