Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Is it possible to create more than 1 report ? Post Reply Post New Topic
Author Message
btough
Newbie
Newbie
Avatar

Joined: 14 May 2009
Online Status: Offline
Posts: 30
Quote btough Replybullet Topic: Is it possible to create more than 1 report ?
     Posted: 17 Jun 2009 at 2:30am
I have created a application, in which I provide some options to user. These options are used to build the query. User select these options and when press "Create Report" button, my application create a query according to user selected options and generate the report. Now when user select another options and press "Create Report" button, previous report get replace with new report. That mean at a time only one report can be generated.
     So my requirement is, instead of replacing previous report with new report, it should be fresh new report. Is it possible to generate more than 1 report with different result?
 
Any help will be appreciated.
 
Thanks,
 


Edited by btough - 18 Jun 2009 at 5:06am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 17 Jun 2009 at 7:52am
absolutely.  When you 'create' the report in the app, do something like
dim cr as new frmViewer, yes, I program in VB...for c# it would be what...frmVeiwer cr = New frmViewer ();  this will create a new instance of the control and will allow multiple reports to be displayed.
 
We only wanted 1 copy, so I search for the mdichildren collection to prevent duplication.
 
HTH
IP IP Logged
btough
Newbie
Newbie
Avatar

Joined: 14 May 2009
Online Status: Offline
Posts: 30
Quote btough Replybullet Posted: 17 Jun 2009 at 8:43am
Thank you lockwelle,
 
     My crystal report viewer name is crystalReportViewer2.
 
I use  -
crystalReportViewer2.ReportSource = rptDoc;
 
And it displays the report.
 
As per your suggestion, if I use -
 
 

CrystalDecisions.Windows.Forms.CrystalReportViewer viewer = new CrystalDecisions.Windows.Forms.CrystalReportViewer();

viewer.ReportSource = rptDoc;

it display blank report.
 
Any suggestion will be appreciated.
 
Thanks,


Edited by btough - 18 Jun 2009 at 4:46am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Jun 2009 at 6:34am

Dim cr As CrystalDecisions.CrystalReports.Engine.ReportDocument

Dim vwr As New frmReport

Try

cr = crReport 'set the dataset

cr.SetDataSource(dsReport) 'set the report to display

vwr.crvReport.ReportSource = cr

vwr.Text = Me.Text

vwr.Name = Me.Text

vwr.MdiParent = Me.ParentForm

vwr.Show()

Catch ex As Exception

End Try

Here is my code.  I am pretty sure that this will create multiple reports as I have removed the code that checks for prior existance.  In the past our app had multiple reports (every time you ran the report, you got a new viewer, but someone decided that, that was a bad thing).  Should be simple enough to translate to C#.
 
HTH
IP IP Logged
btough
Newbie
Newbie
Avatar

Joined: 14 May 2009
Online Status: Offline
Posts: 30
Quote btough Replybullet Posted: 18 Jun 2009 at 8:21am
Thank you lockwelle,
 
But still I am confused. Can you please clear what do you mean by frmReport?
 
Appreciate your help.
 
Thank you in advance.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Jun 2009 at 10:04am
I have a form that has the Crystal report viewer on it so that I can set the report as a MDI child form, that is all that frmReport is.
 
HTH
IP IP Logged
btough
Newbie
Newbie
Avatar

Joined: 14 May 2009
Online Status: Offline
Posts: 30
Quote btough Replybullet Posted: 19 Jun 2009 at 2:15am
Thank you lockwelle for help.
 
My CrystalReport Viewer control is on Form2. So every time when user press "Create Report" button from Form1, I created new instance of Form2 i.e. Form2 frm2 = new Form2();. This solved my problem.
 
Thanks.
IP IP Logged
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