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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.
É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

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
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?

Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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

            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")


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


            Me.CrystalReportViewer1.ReportSource = rptDoc

        Catch ex As Exception
        End Try

    End Sub

Open in new window

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

is the path to your report valid?
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

    End Sub

Open in new window

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

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.
dave_skyAuthor Commented:
I should have mentioned that the viewer is not displaying.
É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!
dave_skyAuthor Commented:
I finally found the problem: Incorrect code after copy...

Thanks for your help!
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.