?
Solved

How to run multiple Crystal report with single Click event in VS2010 + VB.NET

Posted on 2012-09-14
3
Medium Priority
?
1,350 Views
Last Modified: 2012-10-13
Hi,

At the click of the button I want to launch 2 crystal reports at a time....

I am calling 2 different functions under Button_click to show the 2 crystal reports.

The form and Crystalreportviewer for both functions are different.

Under function1:
 frmCrystalReport.CrysRepViewer.ReportSource = rptMain
 frmCrystalReport.Text = "Detail Reporting"
 frmCrystalReport.ShowDialog()
 frmCrystalReport.Dispose()

Under Function 2:
 frmCrystalReport2.CrysRepViewer2.ReportSource = rptMain
 frmCrystalReport2.Text = "Summary Reporting"
 frmCrystalReport2.ShowDialog()
 frmCrystalReport2.Dispose()

  After clicking the button only report 1 opens successfully and only after closing that report the next report opens.

Could someone help me how to make both crystal report open at a time?
(remember I am loading the reports in two different forms)
0
Comment
Question by:anbu210
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
vasto earned 900 total points
ID: 38410441
This is happenning because you have ShowDialog() which stops the execution. Change your code to :

 Under function1:
 frmCrystalReport.CrysRepViewer.ReportSource = rptMain
 frmCrystalReport.Text = "Detail Reporting"
 frmCrystalReport.Show()

Under Function 2:
 frmCrystalReport2.CrysRepViewer2.ReportSource = rptMain
 frmCrystalReport2.Text = "Summary Reporting"
 frmCrystalReport2.ShowDialog()
 frmCrystalReport.Dispose() 
 frmCrystalReport2.Dispose()

Open in new window



if frmCrystalReport is not available in Function2 then you might need to define it on a class level or in Button_click and dispose it in  Button_click after Function 2 is called
0
 

Assisted Solution

by:anbu210
anbu210 earned 0 total points
ID: 38441463
Thanks for Suggesting the mistake I committed.

But If I use the above code it opens both report but I am able to click and view the pages of the 2nd report. While the first report is disabled to click and it is behind the 2nd report.

If I close the 2nd report, then 1st report Automatically closes.

So I added frmCrystalReport.Show() and frmCrystalReport2.Show() in both funtion.
But due to dispose(). after clicking on show report. Both reports opens and close automatically within a second.

So finally removed dispose() in end funciton.

and add below code to the btn_show click

     If frmCrystalReport.Visible = True Or frmCrystalReport2.Visible = True Then
            MessageBox.Show("Please close the open reports before continuing.")
            btnShow.Enabled = False
            Exit Sub
        End If
0
 

Author Closing Comment

by:anbu210
ID: 38492532
There was some more changes to be done with solution provided by Vasto..My Solution fixed my issue. But Vasto helped me to identify the cause
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses

601 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