[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Passing Crystal Reports SelectionFormula along to a subreport

Posted on 2008-06-11
4
Medium Priority
?
1,062 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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 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