943,816 Members | Top Members by Rank

Ad:
Aug 28th, 2008
0

How to load crystal Report in my Visual Basic Apllication ?

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
imagetvr is offline Offline
5 posts
since Aug 2008
Aug 28th, 2008
0

Re: How to load crystal Report in my Visual Basic Apllication ?

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.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'use whatever is the path of your report
  2. 'i have assumes that the rpt file is
  3. 'in the application path itself
  4. CrystalReport1.ReportFileName = App.Path & "\studentregister.rpt"
  5. 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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Aug 28th, 2008
0

Re: How to load crystal Report in my Visual Basic Apllication ?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
imagetvr is offline Offline
5 posts
since Aug 2008
Aug 28th, 2008
0

Re: How to load crystal Report in my Visual Basic Apllication ?

use crystal report activex control not CRViewer.

Regards
Shaik Akthar
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Aug 28th, 2008
0

Re: How to load crystal Report in my Visual Basic Apllication ?

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.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'Declare these variable globally in the form module
  2. Dim crxApp As New CRAXDDRT.Application
  3. Dim crxReport As New CRAXDDRT.Report
  4. '-------------------------------------------------------------------------------------
  5.  
  6. Private Sub cmdShowReport_Click()
  7.  
  8. 'Set the report object
  9. Set crxReport = crApp.OpenReport (App.path & "\studentregister.rpt")
  10.  
  11. 'Enables the Viewer's Navigation Controls
  12. CRViewer.EnableNavigationControls = True
  13.  
  14. 'Disable Group Tree
  15. CRViewer.DisplayGroupTree = False
  16.  
  17. 'Enable export button
  18. CRViewer.EnableExportButton = True
  19.  
  20. 'Disables the CRViewer's Search control
  21. CRViewer.EnableSearchControl = True
  22.  
  23. 'Set the report source
  24. CRViewer.ReportSource = crxReport
  25.  
  26. 'View the report
  27. CRViewer.ViewReport
  28.  
  29. End Sub


Hope this helps u.

Regards
Shaik Akthar
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Aug 29th, 2008
0

Re: How to load crystal Report in my Visual Basic Apllication ?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
imagetvr is offline Offline
5 posts
since Aug 2008
Aug 29th, 2008
0

Re: How to load crystal Report in my Visual Basic Apllication ?

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 = crxApp.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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Sep 2nd, 2011
0
Re: How to load crystal Report in my Visual Basic Apllication ?
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lenn13 is offline Offline
2 posts
since Aug 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: vb6 .exe run without installed vb6
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Input a MYSQL row value to a TextBox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC