Solved

Passing Crystal Reports SelectionFormula along to a subreport

Posted on 2008-06-11
4
1,051 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
Comment Utility
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
Comment Utility
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
Comment Utility

"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
Comment Utility
You are correct, in that scenario you need to use subreports.

mlmcc
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now