Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use CRViewer in VB please help

Status
Not open for further replies.

k144

Instructor
Jul 24, 2004
2
US
I am using VB6 and crystal report 8.5, I have report done in crystal report and I want to see this report in vb form by using crviewer control. I have the crviewer control in my tool bar, I placed the component in the form but don't know how to write the code. Please help me, thank you in advance.
 
The following code works assuming you have a connection to he database or datasource:

You first need to declare your Crystal objects as follows

Dim lReportApp As CRAXDDRT.Application
Dim lReportDatabase As CRAXDDRT.Database
Dim lReportTables As CRAXDDRT.DatabaseTables

Then set your Crystal objcts

Set lReportApp = New CRAXDDRT.Application

'strReportLocation is a variable representing where the report is, you could hard code the path of the actual report
Set lrptReport = lReportApp.OpenReport(strReportLocation)
Set lReportDatabase = lrptReport.Database
Set lReportTables = lReportDatabase.Tables

Then set your report viewer equal to your data source which could be a strsql statement, the results of a function, a table in a database, etc

lReportTables = strSql
crviewer.reportsource = lReportTables

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top