954,173 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to load crystal Report in my Visual Basic Apllication ?

Hello

I wish to call crystal report in my VB6 Application.

For showing data report i used following code ;

Example

Date report name : datareport1
Code for showing report

Load datareport1
Datreport1.show

I have crystal report named "studentregister". please explain me how can show the crystal report in my vb6 application ?

A.Senthil

imagetvr
Newbie Poster
5 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

If crystal report is installed, then u can find the Crystal Report Viewer OCX control in VB IDE in the components. Add the crystal report control to your form and configure it to show the required report.

'use whatever is the path of your report
'i have assumes that the rpt file is
'in the application path itself
CrystalReport1.ReportFileName = App.Path & "\studentregister.rpt"
CrystalReport1.Action = 1


Many other properties are also available for the control like to enable print button, to export the report, navigation of pages etc.

Hope this solves ur problem


Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

Thanks Mr. Shaik Akthar

I added Crystal Report Viewer in components

I used your code to view report i got following error message.

Please help to solve

compile error
Method or Data Member not found

Thanks
senthil kumar.A

imagetvr
Newbie Poster
5 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

use crystal report activex control not CRViewer.

Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

CRViewer can also be used, but the coding will be slightly different

Add the Crystal App references and CrViewer component in References and Components respectively.

'Declare these variable globally in the form module
Dim crxApp As New CRAXDDRT.Application
Dim crxReport As New CRAXDDRT.Report
'-------------------------------------------------------------------------------------

Private Sub cmdShowReport_Click()

 'Set the report object
 Set crxReport = crApp.OpenReport (App.path & "\studentregister.rpt")

 'Enables the Viewer's Navigation Controls
 CRViewer.EnableNavigationControls = True

 'Disable Group Tree
 CRViewer.DisplayGroupTree = False

 'Enable export button
 CRViewer.EnableExportButton = True

 'Disables the CRViewer's Search control
 CRViewer.EnableSearchControl = True

 'Set the report source
 CRViewer.ReportSource = crxReport

 'View the report
 CRViewer.ViewReport

End Sub

Hope this helps u.

Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

Thanks a lot Mr. Shaik Akthar

Again i disturb you . I added your code but i got error message

Dim crxApp As New CRAXDDRT.Application
Dim crxReport As New CRAXDDRT.Application

Set crxReport = crApp.OpenReport(App.Path & "\studentregister1.rpt")
( here i got error message " Variable not defined ) ( crapp )

CRViewer.EnableNavigationControls = True
CRViewer.DisplayGroupTree = False
CRViewer.EnableExportButton = True
CRViewer.EnableSearchControl = True
CRViewer.ReportSource = crxReport
CRViewer.ViewReport

imagetvr
Newbie Poster
5 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Hi!
Just change the variable name please, i typed it wrong as crApp instead of crxApp.

Dim crxApp As New CRAXDDRT.Application
Dim crxReport As New CRAXDDRT.Application

Set crxReport = <strong>crxApp</strong>.OpenReport(App.Path & "\studentregister1.rpt")
( here i got error message " Variable not defined ) ( crapp )

CRViewer.EnableNavigationControls = True
CRViewer.DisplayGroupTree = False
CRViewer.EnableExportButton = True
CRViewer.EnableSearchControl = True
CRViewer.ReportSource = crxReport
CRViewer.ViewReport


Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

hello , anybody can help me with this code for crviewer, i am beginner in vb and i am havng hard time with this crviewer, the error of this , OBJECT VARIABLE OF BLOCK OF VARIABLE NOT SET,please help...


Private Sub Command1_Click()
Dim oapp As CRAXDDRT.Application
Dim oreport As CRAXDDRT.Report
rs.Open "select * from products_info", cn, adOpenKeyset, adLockOptimistic
Set oapp = New CRAXDDRT.Application
Set oreport = oapp.OpenReport(App.Path + "\report1.rpt", 1)
oreport.databse.SetDataSource rs, adOpenKeyset, adlockpotimistic

CRViewer1.ReportSource = oreport
CRViewer.ViewReport

End Sub

lenn13
Newbie Poster
2 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You