Object reference not set to an instance of an object.

I get this error message when trying to open a crystal report from a windows application.

Can someone help?

Thanks!
dave_skyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
That means that the object you are trying to access does not exist yet or is set to null.
0
Éric MoreauSenior .Net ConsultantCommented:
Can you show us some code? You surely have an object declared but not initialized (new).

Also, have a look at http://emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mlmccCommented:
Need to know the version of Crystal you are using and the code you are using to display the report.

Is this on the development machine or the client or a web application?

If the client what did you install on the client or server?

mlmcc
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

dave_skyAuthor Commented:
The version of CR that comes with VS 2005 and it is on the development machine.

Private Sub Load_Report()
        Dim rptDoc As New ReportDocument
        Dim dsSql As New DataSet
        Dim iCount As Integer
        Dim sReportPath As String = String.Empty
        Try

            CrystalReportViewer1.ReportSource = Nothing
            dsSql = Get_SampleDataset()
            sReportPath = Application.StartupPath

            ''Path to Bin

            rptDoc.Load("C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Crystal Reports\CrystalReportNPGCheckList.rpt")

            ''rptDoc.Load("C:\Deploy\CrystalReportNPGCheckList.rpt")

            For iCount = 0 To rptDoc.Database.Tables.Count - 1

                rptDoc.Database.Tables(iCount).SetDataSource(dsSql.Tables(iCount))
            Next

            Me.CrystalReportViewer1.ReportSource = rptDoc


        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            dsSql.Dispose()
        End Try

    End Sub

Open in new window

0
Éric MoreauSenior .Net ConsultantCommented:
on which line does the error occurs?

is the path to your report valid?
0
dave_skyAuthor Commented:
The error occurs at this point:
 Private Sub frmNewPlumbingGCheckListCRV_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Load_Report()
        CrystalReportViewer1.Zoom(91)

    End Sub

Open in new window


The path to the report is definitely valid.
0
Éric MoreauSenior .Net ConsultantCommented:
Can you get the exact line where the error occurs?
0
mlmccCommented:
Is the Load _Report subroutine on the same form?

mlmcc
0
dave_skyAuthor Commented:
I lost the connection to the report when I copied a similiar report and viewer and updated the code on the new report and viewer.

I have several other crystal reports that are working fine.
0
dave_skyAuthor Commented:
I should have mentioned that the viewer is not displaying.
0
Éric MoreauSenior .Net ConsultantCommented:
we have already asked to identify the exact line causing the error. That would help us. Otherwise, we are completely blind here!
0
dave_skyAuthor Commented:
I finally found the problem: Incorrect code after copy...

Thanks for your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.