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

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

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

use crystal report activex control not CRViewer.

Regards
Shaik Akthar

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

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

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 = [B]crxApp[/B].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

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

Can i change sql query from vb while using CRAXDDRT????

Sanket, yes you can. This thread is however 4 years old and belongs to a different poster. You need to open your own thread OR you can post your code under the one that you have opened earlier...

As was mentioned in your earlier post, we do not recognise the code. If you look at the code above in this thread, you will see the difference.

Hi,
Please tell me how to call crystal report in VB6.0 with oracal database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.