Showing posts with label VB.NET Crystal Reports. Show all posts
Showing posts with label VB.NET Crystal Reports. Show all posts

VB.NET Crystal Reports Summary Fields


The following C# - Crystal Reports section describes how to add a summary field in the Crystal Reports
In the Crystal Reports designer view window, right click on the Report Footer , just below the Total field and select Insert -> Summary .


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

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

Now the designing part is over and the next step is to call the Crystal Reports in C# and view it in Crystal Reports Viewer control .

Select the default form (Form1.cs) you created in C# and drag a button and a CrystalReportViewer control to your form .

You have to include CrystalDecisions.CrystalReports.Engine in your C# Source Code.

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

VB.NET Crystal Reports Formula Fields

If you have a Crystal Reports with Qty and Price , you need an additional field in your Crystal Reports for the Total of QTY X PRICE . In this situation you have to use the Formula Field in Crystal Reports.
In this tutorial we are showing the all orders with qty and price and the total of each row , that means each in each row we are showing the total of qty and price. Before starting this tutorial.
Create a new Crystal Reports with fields CustomerName , Order Date , Product Name and Product Price . If you do not know how to create this report , just look the previous tutorial Crystal Report from multiple tables . In that report selecting only four fields , here we need one more field Prodcut->Price .
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.

How to Create a Formula in Crystal Reports XI,VB.NET Crystal Reports Formula Fields

Formulas serve many purposes and in my example I am going to show you how I am able to combine to fields from a database to create one complete field. This How-To assumes that you have worked through my previous How-To article of creating a simple report. It is this simple report I am going to use.
  1. Open Crystal Reports XI
  2. Step 2
    Open the simple report you created rfom my previous how-to article.
  3. Step 3
    Right click
     
    Right click
    On the field explorer, right click on Formula Fields.
  4. Step 4
    New
     
    New
    Select "New" from the popup menu.
  5. Step 5
    FullName
     
    FullName
    Give your formula the name, "FullName".
  6. Step 6
    Ok
     
    Ok
    Click the ok button.
  7. Step 7
    Expand
     
    Expand
    The formula workshop window will appear. In here we are going to combine the last name database field, with the first name database field to create the formula "FullName." Expand the window that displays the database fields by clicking on the [+] plus sign. See image.
  8. Step 8
    Get LastName
     
    Get LastName
    Double click the "LastName" field. This will put it in the formula editor area.
  9. Step 9
    Concatenate
     
    Concatenate
    Add the amerpsand (&) symbol and then in quotations a comma followed by a space and then another ampersand. See the picture for how it looks. This will help separate the last name from the first name with a comma. The ampersand symbols concatenates two strings together.
  10. Step 10
    Get Firstname
     
    Get Firstname
    Double click on the first name field to add it to the formula editor.
  11. Step 11
    Check for Errors
     
    Check for Errors
    Check to make sure the formula does not have any errors in it by clicking the (x+2) button with the green checkmark underneath.
  12. Step 12
    No Errors
     
    No Errors
    You will should receive the message box as shown in the picture. If you receive a different message it means there is an error. Go back through the steps, follow the pictures and try again before you continue.
  13. Step 13
    Save and Close
     
    Save and Close
    Click the "Save and Close" button.
  14. Step 14
    Formula Created
     
    Formula Created
    The formula has been created and exists in the Field Explorer window as shown in the picture.
  15. Step 15
    Formula added to report
     
    Formula added to report
    Add the formula to the report by double clicking the formula name, dragging your mouse to the report and clicking the mouse button to drop it in the details section. Your report should now look like the picture.
  16. Step 16
    Final Report
     
    Final Report
    Press the "F5" key to see how the report with the formula looks. Click the Ok button if you get the message box asking if you wish to refresh the data. The picture shows the final results.