Solved

Passing Crystal Reports SelectionFormula along to a subreport

Posted on 2008-06-11
4
1,056 Views
Last Modified: 2008-06-11
Hey, I'm struggling through incorporating a crystal report into my ASP.NET web page.  My method is to create a DAO connection to my MDB file in my .rpt, and then on my report form with the CR viewer, I set up a selection formula as in the code below.  As you can see I narrow the report down to a detailed report of a single record.

So now I have to add a second table based on a related database table (the "milestones" associated with my plan record), and apparently I have to do this using a subreport.  I have created a separate, working RPT object that lists ALL of the milestones for all plans, and I added a subreport to my Plan report and connected it to this RPT.  This works fine so far, I open up  my plans report and I see the subreport listing all milestones for all plans, however I'd like to filter this down using the same SelectionFormula so that it only shows records in the subreport that pertain to the main report.  How do I set a SelectionFormula for the subreport from my main webform / report viewer?

A code snippet (hopefully it's that simple) would be *much* appreciated.  Thanks very much...
Partial Class FormReportPlan
    Inherits System.Web.UI.Page
 
    Private customerReport As ReportDocument
 
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
 
        ConfigureCrystalReports()
 
    End Sub
 
    Private Sub ConfigureCrystalReports()
 
        Dim rec As String = Request.QueryString("rec")
 
        customerReport = New ReportDocument()
        customerReport.Load(Server.MapPath("ReportPlan.rpt"))
 
        If Not rec Is Nothing Then
            CrystalReportViewer1.SelectionFormula = "{Plans_View.Plan Number} = '" + rec + "'"
        End If
 
        CrystalReportViewer1.ReportSource = customerReport
 
    End Sub
 
End Class

Open in new window

0
Comment
Question by:riceman0
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
raterus earned 500 total points
ID: 21762104
The answer to your question here is to use Subreport Links (Right click on the subreport in your main report and you'll see the option "Change Subreport links").

You can read up on them as I'm not the smartest with them, but basically you can link data between the reports, so your subreport uses data in the main report to select it's data.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 21762565
WHy do you need to add this as a subreport?

If it is a related table you should be able to simply add the table to the main report and link it appropriately.

To use the subreport links
Right click the subreport
Click CHANGE SUBREPORT LINKS
Select the ID field from the main report
Select the related foield from the subreport field list
CLick the box the select records based on the field

mlmcc
0
 

Author Comment

by:riceman0
ID: 21763276

"WHy do you need to add this as a subreport?"

Please see my accepted answer to this question.  I would love to do this more simply.

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23469076.html

"If it is a related table you should be able to simply add the table to the main report and link it appropriately."

Do you still think I can do this?  I want several different tables/lists.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 21765687
You are correct, in that scenario you need to use subreports.

mlmcc
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question