I am new to integrating Crystal Reports into VB applications so please bear with me. I am trying to created a basic report viewer that can be used without accessing the full program. I am trying to keep certain reports from being modified which has been an issue in the past. It seemed to be a simple program but I keep getting an "Object reference not set to an instance of an object" error when running the code.
I have two forms: one with a drop-down list that has all the reports that you can choose and an open button, and another form with the Crystal Reports Viewer Control on it.
Any help is appreciated. Thanks.
Here is my code to help:
This is the Code for my main form:
This is the code for the Crystal Report Viewer form:
I have two forms: one with a drop-down list that has all the reports that you can choose and an open button, and another form with the Crystal Reports Viewer Control on it.
Any help is appreciated. Thanks.
Here is my code to help:
This is the Code for my main form:
VB.NET:
Imports System.IO
Public Class frmCrystalReportsViewer
Inherits System.Windows.Forms.Form
#Region "Main"
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Dim rptName As String
rptName = cmbSelectReport.SelectedItem
Dim newCrystal As New CrystalReport
newCrystal.FileName.Text = rptName [COLOR=red]<This is where I get the object reference error[/COLOR]
newCrystal.ShowDialog()
End Sub
#End Region
End Class
This is the code for the Crystal Report Viewer form:
VB.NET:
Imports AxCRVIEWER9Lib.AxCRViewer9
Public Class CrystalReport
Inherits System.Windows.Forms.Form
Dim CrApp As New CRAXDRT.Application
Dim CrReport As New CRAXDRT.Report
Private Sub Reports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CrReport = CrApp.OpenReport("FileName.Text", 1)
AxCRViewer91.ReportSource = CrReport
AxCRViewer91.ViewReport()
End Sub
End Class