VB.Net-Informations.com
   Home      .Net Framework      VB.NET      C#                                                                      About


  Create a Subreport in Crystal Reports

Subreport in Crystal Reports means a Report within a Report . When we want to show some additional information about the data in the Crystal Reports , we use the subreports to show the details. Subreports we show within the main Crystal Reports and also we can show it as On-Demand report , that means we put an Hyper link in the row, and when user click that hyper link then will get the subreport.

This section we are showing the subreport within the Crystal Reports . That is for each row there is a subreoprt for the details.

vb.net_crystal_report_subreport_0.GIF

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 .

Here we are create an order report based on three tables in the database and show a subreoprt for each row of the specified Product Name. Here we are using our earlier program Crystal Report from multiple tables to show the main Crystal Reports Data , so please refer Crystal Report from multiple tables before start this section .

Create a Crystal Reports using three tables and select customername , date , product and qty . It will explain in detail the previous section Crystal Report from multiple tables .

Next step is to create a subreport inside the main report. Here we are showing the Product details in each row of the specified product in the main row.

After create the main report , right click on Crystal Reports designer window and select Insert-Subreport.

vb.net_crystal_report_subreport_1.GIF

Then you will get the subreport object , drag the object in the designer window at the down part of the details tab , just below the fields in the details tab. When you release the mouse you will get a dialogue box asking report name . Enter the report name you want and click the Report Wizard button.

The wizard shows the table selection screen and select the table . Here in this case we are selecting the Product Table from the list and click next .

Next screen is showing the table , from there select the fields you want to show the data and click finish. The you will get the subreport main screen again and select Link tab .

The link tab is making relation with your main Report and subreport . Here we are linking the productname from main report to the subreport. For that select Product.Product_name from Available fields.

vb.net_crystal_report_subreport_2.GIF

Accept the other settings as it is in the screen and click ok. Now you can see the subreport object in the screen , if you want to modify subreport design , double click on subreport object and you can design subreport.

vb.net_crystal_report_subreport_3.GIF

Now the designer part is over . Next step is to select the default form(Form1.vb) and add a Button and Crystal Reports Viewer to the Form.

Put the following vb.net source code in your form and run the program .

         VB.NET Source Code Download           Print Source Code
         Create a Subreport in Crystal Reports - Download
        
C# Tutorial

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 crp As New CrystalReport1
        CrystalReportViewer1.ReportSource = crp
        CrystalReportViewer1.Refresh()
    End Sub
End Class



VB.NET Crystal Reports Related Contents
*     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 Formula Fields
*     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 with Link
*     How to deploy Crystal Reports on Clinet Machine
*     How to create Crystal Reports installer using Merge Modules


   Home      VB.NET      C#
VB.Net Related Topics
*     Microsoft .Net Framework Tutorials
*     VB.NET Language Basics Tutorials
*     VB.NET Program Flow Control Tutorials
*     VB.NET Collections Tutorials
*     VB.NET String Tutorials
*     VB.NET Files Tutorials
*     VB.NET Excel 2007 Tutorials
*     VB.NET Crystal Reports Tutorials
*     VB.NET Communications Tutorial
*     VB.NET ADO.NET Tutorial
*     ADO.NET Data Providers help and Tutorial
*     VB.NET ADO.NET Dataset Tutorial
*     ADO.NET DataAdapter and Dataset
*     VB.NET ADO.NET DataView Tutorial
*     VB.NET Remoting Tutorial
*     VB.NET XML Tutorial
*     VB.NET DataGridView Tutorial
   Home      VB.NET      C#
More Source Code :   
Mail to :  feedback@net-informations.com
  |  Home   |  VB.NET   |  C#   |  SiteMap   |  Terms of Use   |  About   |
net-informations.com (C) 2010
All Rights Reserved. All other trademarks are property of their respective owners.