Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: more than 1 report bind to CrystalReportViewer Post Reply Post New Topic
Author Message
RealQMan
Newbie
Newbie
Avatar

Joined: 22 Aug 2007
Online Status: Offline
Posts: 25
Quote RealQMan Replybullet Topic: more than 1 report bind to CrystalReportViewer
    Posted: 12 Oct 2007 at 2:20pm
Hi All,

There is a question for those who are familiar on working with crystal reports in VS 2005. So, it's possibly you worked with CrystalReportViewer object used as a useful tool to view report. I know how to bind 1 report to the crystalreportviewer for display, but there are probably 1 or more reports that will need to display simulataneously. The most obvious and straightforward solution is to include as much crystalreportviewer objects as the report and bind them accordingly. But isn't it more efficient if i can just bind 1 or more reports to just 1 crystalreportviewer object. How do i write it?


IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 15 Oct 2007 at 9:18am
You are right that you will have to use multiple viewer objects. CR only allows one report per viewer object.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
wattsjr
Groupie
Groupie
Avatar

Joined: 25 Jun 2007
Location: United States
Online Status: Offline
Posts: 51
Quote wattsjr Replybullet Posted: 15 Oct 2007 at 3:05pm
Hi RealQMan,
 
I've taken a slightly different approach, so I don't know if this is the kind of thing that you're asking about, but it works for me. Now, I'm using VB2003, so if that makes a difference just ignore the rest.
 
What I did was to:
Create my reports and save them separate (not imbnedded) from the VB app.
 
Create a sub-form and called it frm(application)Report,
 
Added a CrystalReportViewer, a reportDocument and a OleDbConnection to the form.
 
Sized the Viewer to fill the whole form
 
Then I coded a Sub-routine with the following:
 
Private Sub ....vViewer.....
' create a virtual copy of the form
Dim vAppNameReport As New frmAppNameReport()
 
' Pass the vForm te CR.rpt path & name
vAppNameReport.CrystalReportViewer1.ReportSource = crReportDocument
 
' Check for Selection criteria in the report. If there is any, merge it with the Selection criteria from the VB App.
If Len(crReportDocument.RecordSelectionFormula) > 5 Then
    If Len(Select_String) > 1 Then
        vAppNameReport.CrystalReportViewer1.SelectionFormula = "(" &    crReportDocument.RecordSelectionFormula & ") AND " & Select_String
    Else
        vAppNameReport.CrystalReportViewer1.SelectionFormula = "(" &  crReportDocument.RecordSelectionFormula & ")"
    End If
  Else : vAppNameReport.CrystalReportViewer1.SelectionFormula =  Select_String
 End If
 
' Pass various properties to the form
vAppNameReport.Text = gReportName
vAppNameReport.CrystalReportViewer1.Dock = DockStyle.Fill
vAppNameReport.Visible = True
vAppNameReport.BringToFront()
vAppNameReport.CrystalReportViewer1.Visible = True
vAppNameReport.CrystalReportViewer1.BringToFront()
 
Then I created a button for each report and called the sub-routine from the buttons subroutine with the following:
 
gSelString = txtComplaintID.Text
gReportSource = gfilePath & "CRreportname.rpt"
gReportName = "Title"
 
' Called the vViewer sub-routine, passing it various parms wich were used to supply login criteria
' to other parts of the sub-routine.
Me.SendToBack()
vViewer(gID, gPWD, gServerName)
 
This setup gives me the ability to view several reports at a time, each one using a virtual viewer.
I hope this is useful to you,
-jrw
IP IP Logged
RealQMan
Newbie
Newbie
Avatar

Joined: 22 Aug 2007
Online Status: Offline
Posts: 25
Quote RealQMan Replybullet Posted: 09 Nov 2007 at 11:39am
hi, i've been working on other reports, but now i have time to get back to print multiple reports...

Your virtual viewer is more robust and flexible than mine was. I had a similar idea before posting, which was to display one report with one virtual viewer. Basically one to one relationship.. the scenario i am facing will require all the reports to be view at once... So, if there's 5 reports for 5 different customers, than all 5 are view... Using the code we have now, it will require 5 instance of virtual viewer. The application takes a performance hit dramatically.

Thanks anyways, it was a great post.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.