Solved

Passing Crystal Reports SelectionFormula along to a subreport

Posted on 2008-06-11
4
1,059 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 101

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 101

Expert Comment

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

mlmcc
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 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