Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening rpt files with crystal viewer

Status
Not open for further replies.

DirectOne

IS-IT--Management
Dec 26, 2002
62
US
I have a crystal report viewer program that prints a views crystal reports, I have an installer package that installs all the required files and associates rpt's with the app.

My problem is when I select a rpt file the viewer opens but does not display the report.

I must be missing a step. Help?
 
I have a form with a File menu with Open, it calls openreport


Code:
Imports CrystalDecisions.CrystalReports.Engine

Sub openreport()

        'Check user settings and then open report based on the options form

        If readXMLValue("filelock") = "Y" Then

            Try
                FileViewer1.Visible = True

                FileViewer1.Path = readXMLValue("defaultpath")

            Catch
                MessageBox.Show("Default Path not Set In options", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

                End

            End Try

        Else

            Dim myDialogResult

            Try
                cr_OpenFileDialog1.InitialDirectory = readXMLValue("defaultpath")
            Catch
                cr_OpenFileDialog1.InitialDirectory = "C:\"
            End Try

            myDialogResult = cr_OpenFileDialog1.ShowDialog()

            If myDialogResult = DialogResult.OK Then
                selectedreport = New ReportDocument
                selectedreport.Load(cr_OpenFileDialog1.FileName)
                CrystalReportViewer1.ReportSource = selectedreport
                FileViewer1.Visible = False

            End If
        End If
 
The three primary lines you need are:
Code:
dim cr as New CrystalDecisions.CrystalReports.Engine.ReportDocument()
cr.Load(ReportPath & ReportName)
CrystalReportViewer1.ReportSource = cr

Which it looks like you have. I would suggest steping through your code and making sure the execution is matching your expectations.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I can view and print the reports just fine using the file open method, What I want to do is associate my viewer with rpt files, and be able just to double click an rpt file and have it open the viewer and display the report.

Do I need to use command line arguments to accomplish this?

Thanks,

Bob Zaback
 
Yes, you'll need to do two thing, first add the command line parameter parsing to your application. And second, set up the file association. I think Chrissie posted an excellent write up on how to make a file association a few weeks ago, try searching the forum.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top